Trying to redirect every urel request to test.py script with thevisitors page request as url paramet

Discussion in 'Python' started by Íßêïò, Jul 20, 2010.

  1. Íßêïò

    Íßêïò Guest

    Hello guys! This is my first post in this group!
    I'am trying to create a python script to take a visitors page request
    as url parameter, and the insert or update the counters database table
    and the render the template(my tempalets are actually html files) that
    has int hem special strign identifies format charactes so to replace
    them with actual data form within my python script.

    While the mod_rewwrite redirects okey

    when i try to http://webville.gr apache by default tries to open
    idnex.html file right?

    but due to

    Code:
    RewriteEngine On

    RewriteCond %{REQUEST_FILENAME} -f
    RewriteRule ^/?(.+) /cgi-bin/test.py?page=$1 [L,PT]


    redirectes the url to test.py script and i expect it to give to my
    pythoin script the initial url before the mod_rewrite as a URL
    parameter.

    while i tested and my script works ok(its a simple test cghi script
    afgter all)

    when i enable out mod_rewriute code within the htaccess file i get an
    Internal Server Error

    You can see if you try to http://webville.gr/index.html

    whiel if i disbale mod_rewrite code my test.py script work proiducing
    results.

    That leads me to beleive that the intiial requests never passes as url
    parameter.

    my python script is this simple script:

    Code:
    #!/usr/bin/python
    # -*- coding: utf-8 -*-

    import cgitb
    import os, sys, socket, datetime
    cgitb.enable()

    print ( "Content-type: text/html\n" )


    # get some enviromental values
    if os.environ.has_key('HTTP_REFERER'):
    page = os.environ['HTTP_REFERER']
    else:
    page = "tipota"

    host = socket.gethostbyaddr( os.environ['REMOTE_ADDR'] )[0]
    date = datetime.datetime.now().strftime( '%y-%m-%d %H:%M:%S' )

    print page, host, date


    Can you help please?
    Also i want the code to redirect to test.py only if the initial
    request is a .html page not with every page.

    Thanks again!
    Íßêïò, Jul 20, 2010
    #1
    1. Advertising

  2. 2010/7/20 Íßêïò <>:
    > Hello guys! This is my first post in this group!


    I do not have an answer to your question, other than to suggest you
    look at (and/or post) relevant lines from Apache's access.log and
    error.log.

    I write mostly to say that, in my experience, folks on this list are
    very helpful, but your post has many, many spelling errors, making it
    difficult to read. It looks like you are using Gmail, which has a
    "Check Spelling" drop-down on the compose window. If you re-post with
    better spelling you might get more responses.
    Jason Friedman, Jul 21, 2010
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jon paugh
    Replies:
    1
    Views:
    687
  2. Paul

    redirect on every request

    Paul, Jul 5, 2007, in forum: ASP .Net
    Replies:
    3
    Views:
    303
  3. =?Utf-8?B?SXJ3YW5zeWFo?=
    Replies:
    4
    Views:
    2,441
    =?Utf-8?B?SXJ3YW5zeWFo?=
    Oct 30, 2007
  4. John Kotuby
    Replies:
    0
    Views:
    356
    John Kotuby
    Aug 18, 2008
  5. Sal
    Replies:
    1
    Views:
    381
Loading...

Share This Page