SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Nov 2007
    Posts
    117
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Redirect not working

    Hi,

    I have the following rewrite, but it doesn't seem be happening.

    Any ideas why its not working?

    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] 
    Thanks

  2. #2
    Utopia, Inc. silver trophy
    ScallioXTX's Avatar
    Join Date
    Aug 2008
    Location
    The Netherlands
    Posts
    9,031
    Mentioned
    152 Post(s)
    Tagged
    2 Thread(s)
    You can't put the schema, domain and query string in the RewriteRule, plus . should be escaped as \. because dots have a special meaning in regular expressions. It should be

    Code:
    RewriteCond %{QUERY_STRING} ^ref=ref1$ 
    RewriteRule ^subfolder/page1\.shtml$ /subfolder/page2.shtml?ref=ref2 [R=301,L]
    (you could leave the http://www.domain.com in the RewriteRule for the destination, but if the domain doesn't change I'd recommend against this. It's not needed and easier to change domain names later if you ever need to).

    Rémon - Hosting Advisor

    Minimal Bookmarks Tree
    My Google Chrome extension: browsing bookmarks made easy


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •