Redirect index.php but not index.php?u=2

Discussion in 'Apache' started by fordP, Aug 12, 2008.

  1. #1
    Is it possible to redirect, say, index.php, but not redirect index.php?u=4 or ANY url containing characters such as that?

    I need desperately to do this, but I have yet to find a method. If anyone has an idea, I would greatly appreciate it
     
    fordP, Aug 12, 2008 IP
  2. plaggypig

    plaggypig Peon

    Messages:
    33
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    RewriteRule ^/index.php$ somewhere_else.php
     
    plaggypig, Aug 14, 2008 IP
  3. fordP

    fordP Peon

    Messages:
    548
    Likes Received:
    28
    Best Answers:
    0
    Trophy Points:
    0
    #3
    thanks for the response!

    unfortunately the snippet you posted doesn't work for me
     
    fordP, Aug 15, 2008 IP
  4. fordP

    fordP Peon

    Messages:
    548
    Likes Received:
    28
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Is this not possible?
     
    fordP, Aug 25, 2008 IP
  5. kulinar

    kulinar Member

    Messages:
    45
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #5
    Yep, it is possible. But you have to make directives for any URL that you want to redirect.

    Redirect 301 /index.php http://theredirectedtobe.domain.com
    Redirect 301 / http://theredirectedtobe.domain.com

    and so on.

    If you want to redirect particular parameters in URL, then you can use this
    Options +FollowSymlinks
    RewriteEngine On
    
    RewriteCond %{QUERY_STRING} ^PHPSESSID [OR]
    RewriteCond %{QUERY_STRING} ^f=
    RewriteRule .* %{REQUEST_URI}? [R=301,L]
    Code (markup):
    Any parameter can be added.
     
    kulinar, Aug 26, 2008 IP