mod rewrite with a ?

Discussion in 'Apache' started by 007c, Jan 6, 2008.

  1. #1
    Hi , i've looked a lil into it and can't find really anything relevant.

    I'm trying to rewrite a url in the form of http://www.mysite.com/script.php?something=http or www
    To
    access restricted.

    However http://www.mysite.com/script.php?something=0 must stay the same. i tried using the escape character (\?) but anything after the "?" don't seem to get checked via regex ...
    Is there any way?

    I read something about apache not supporting this...

    Thanx for any help.
     
    007c, Jan 6, 2008 IP
  2. joebert

    joebert Well-Known Member

    Messages:
    2,150
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    145
    #2
    Why do you need the address to stay the same ?

    Without knowing exactly what you're trying to do all I can offer is this.
    RewriteEngine On
    RewriteCond %{QUERY_STRING} somthing=(http|www)
    RewriteRule ^script\.php$ script.php [forbidden,last]
    Code (markup):
    It will send a 403-forbidden HTTP status back to the browser, the browser will remain at that URL, but "script.php" will never be executed because sending a 403 status immediately terminates the request.
     
    joebert, Jan 7, 2008 IP
    007c likes this.
  3. 007c

    007c Peon

    Messages:
    611
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanx i'll give it a try, it's to countermeasure a xss vuln. I thought i needed to add a ^(.*) before something= now i get it tho %{QUERY_STRING} stands for what's after the "?" right? apache's manual is pretty vague...
     
    007c, Jan 7, 2008 IP
  4. joebert

    joebert Well-Known Member

    Messages:
    2,150
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    145
    #4
    joebert, Jan 7, 2008 IP
  5. 007c

    007c Peon

    Messages:
    611
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thanx added some rep+
     
    007c, Jan 8, 2008 IP