htaccess redirect /test/anything.htm to /destination/ ?

Discussion in 'Apache' started by Paz, Nov 15, 2007.

  1. #1
    Hi Guys,

    I've been tearing my hair out with this one all morning. I had a simple redirect from an old site to a new url.

    redirect 301 /old/ http://www.example.com/new/

    The problem is that I have some old files in the /old/ directory that are indexed eg
    /old/index.php

    After the above redirect the index.php is being appended to /new/index.php but this url doesn't exist and I'm getting dupe content issues.

    Can anyone suggest a way to stop the old filename being appended to the redirected url ie the whole lot goes to /new/?

    Here's code I've been working with;

    RewriteEngine on
    RedirectMatch (.*)/old/$ http://www.example.com/new/? 
    #RewriteCond %{REQUEST_URI} ^test\&(.*)$ 
    #RewriteRule ^/(.*) http://www.example.com/destination/$1 [L,R=permanent] 
    #RewriteRule ^/(.*) http://www.example.com/destination/$1?%1 [L,R=permanent] 
    #RewriteRule /test/(.*) http://www.example.com/destination/ [R=301,L]
    #redirect 301 /test/ http://www.example.com/destination
    Code (markup):
    BTW I should point out that /new/ doesn't exist as such either - it's served up on the fly.

    Cheers,
    Paz.
     
    Paz, Nov 15, 2007 IP