301 Redirect in htaccess is appending old file name to new url
.htaccess, apache, http-redirect
Solution
It looks like mod_alias and mod_rewrite might be interfering with each other, and possibly itself.
Keep in mind that the `Redirect` directives link two path nodes together. So if you have, say:
Redirect 301 /mtrx/ http://www.zerolinegolf.com/golf-mtrx-for-the-golfer
that statement also takes: `/mtrx/foo/bar/` and redirects it to `http://www.zerolinegolf.com/golf-mtrx-for-the-golferfoo/bar/`.
You should either switch to using `RedirectMatch` or a `RewriteRule`.
For the former:
RedirectMatch 301 ^/videos/?$ http://www.zerolinegolf.com/videos-2
RedirectMatch 301 ^/press-releases-2/?$ http://www.zerolinegolf.com/media
RedirectMatch 301 ^/mtrx/motion-control/?$ http://www.zerolinegolf.com/golf-mtrx-for-the-golfer
RedirectMatch 301 ^/mtrx/pelvis-power/?$ http://www.zerolinegolf.com/golf-mtrx-for-the-golfer
RedirectMatch 301 ^/mtrx/mtrx-score/?$ http://www.zerolinegolf.com/golf-mtrx-for-the-golfer
RedirectMatch 301 ^/mtrx/recommended-drills/?$ http://www.zerolinegolf.com/golf-mtrx-for-the-golfer
RedirectMatch 301 ^/mtrx/?$ http://www.zerolinegolf.com/golf-mtrx-for-the-golfer
For mod_rewrite, you must place these rules BEFORE your wordpress rules:
RewriteRule ^/?videos/?$ http://www.zerolinegolf.com/videos-2 [L,R=301]
RewriteRule ^/?press-releases-2/?$ http://www.zerolinegolf.com/media [L,R=301]
RewriteRule ^/?mtrx/motion-control/?$ http://www.zerolinegolf.com/golf-mtrx-for-the-golfer [L,R=301]
RewriteRule ^/?mtrx/pelvis-power/?$ http://www.zerolinegolf.com/golf-mtrx-for-the-golfer [L,R=301]
RewriteRule ^/?mtrx/mtrx-score/?$ http://www.zerolinegolf.com/golf-mtrx-for-the-golfer [L,R=301]
RewriteRule ^/?mtrx/recommended-drills/?$ http://www.zerolinegolf.com/golf-mtrx-for-the-golfer [L,R=301]
RewriteRule ^/?mtrx/?$ http://www.zerolinegolf.com/golf-mtrx-for-the-golfer [L,R=301]
Problem
I'm using 301 redirect rule in my htaccess file to redirect some old urls to new ones. However, on a few of the redirects, the old file name is appending onto the new url so I'm getting 404 page errors on those. For example, this is my rewrite rule ``` Redirect 301 /mtrx/motion-control/ http://www.zerolinegolf.com/golf-mtrx-for-the-golfer ``` but the page that shows up is ``` http://www.zerolinegolf.com/golf-mtrx-for-the-golfermotion-control ``` This is the whole .htaccess code ``` # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress #REDIRECTS Redirect 301 /videos/ http://www.zerolinegolf.com/videos-2 Redirect 301 /press-releases-2/ http://www.zerolinegolf.com/media Redirect 301 /mtrx/motion-control/ http://www.zerolinegolf.com/golf-mtrx-for-the-golfer Redirect 301 /mtrx/pelvis-power/ http://www.zerolinegolf.com/golf-mtrx-for-the-golfer Redirect 301 /mtrx/mtrx-score/ http://www.zerolinegolf.com/golf-mtrx-for-the-golfer Redirect 301 /mtrx/recommended-drills/ http://www.zerolinegolf.com/golf-mtrx-for-the-golfer Redirect 301 /mtrx/ http://www.zerolinegolf.com/golf-mtrx-for-the-golfer ``` Thanks for the assistance.