#1
  1. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2004
    Posts
    965
    Rep Power
    11

    Redirect not working


    Hi,

    I am trying to redirect the following, but it is not happening. Any ideas why?

    PHP Code:
    RewriteRule ^http://www.domain.com/subfolder/page1.shtml?ref=ref1$ http://www.domain.com/subfolder/page2.shtml?ref=ref2[R=301,L] 
    Thanks!
  2. #2
  3. Come play with me!
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    13,759
    Rep Power
    9397
    Because the first part of a RewriteRule is only the path, which means no domain name and no query string. If you want to look at the query string then you need to use a RewriteCond against %{QUERY_STRING} (as well as the RewriteRule).
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2004
    Posts
    965
    Rep Power
    11
    Thanks, I now have the following, but it still doesn't work:

    PHP Code:
    RewriteCond %{QUERY_STRING} ^ref=ref1$
    RewriteRule ^http://www.domain.com/subfolder/page1.shtml?ref=ref1$ http://www.domain.com/subfolder/page2.shtml?ref=ref2 [R=301,L] 
    Any ideas?

    Thanks
  6. #4
  7. Come play with me!
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    13,759
    Rep Power
    9397
    Looks like you missed my first sentence?
    The first part of a RewriteRule is only the path, which means no domain name and no query string.
    And I didn't think to mention: the leading slash on the path may or may not be necessary, so if
    Code:
    RewriteCond %{QUERY_STRING} ^ref=ref1$ 
    RewriteRule ^/subfolder/page1.shtml$ http://www.domain.com/subfolder/page2.shtml?ref=ref2 [R=301,L]
    doesn't work then try without it. Or make the slash optional.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2004
    Posts
    965
    Rep Power
    11
    Thanks again for the reply, but it still didn't work :/

    I tried with and without the slash and also placed the htaccess file in the root and subfolder.

    Any other ideas?

    Thanks

IMN logo majestic logo threadwatch logo seochat tools logo