SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2007
    Posts
    45
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    .htaccess Redirect junk at the end of the URL

    I've been moving some old pages over to my database system and having to redirect them to the new URL. When I do this I get extra junk on the end of the URL.

    Code:
    Redirect 301 /OLD-URL.htm http://www.mysite.com/NEW-URL.html
    It redirects it to this:
    http://www.mysite.com/NEW-URL.html?url=OLD-URL

    Is there a way to stop this from happening?

  2. #2
    SitePoint Enthusiast
    Join Date
    Jul 2007
    Posts
    45
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Found the answer. Because I have both static and dynamic pages on my side I had to use the following 2 rules:

    Code:
    RewriteCond %{THE_REQUEST} \?\ HTTP [NC]
    RewriteRule .? http://www.motorcyclemonster.com%{REQUEST_URI}? [R=301,L]
    
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^?]*)\?
    RewriteRule !\.php$ http://www.motorcyclemonster.com/%1? [R=301,L]
    The first one redirects all trailing ? (ie www.mysite.com/page.php?)
    The second removes and redirects all NON-PHP extensions. Such as (www.mysite.com/page.php?query=this) would be left alone but
    (www.mysite.com/page2.html?query=that) would be redirected to (www.mysite.com/page2.html). This helps the most with duplicate content problems.


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
  •