I am moving a client from a custom developed PHP site to WordPress. I am now in the process of using 301 Redirects in the .htaccess file to move the old locations to the new ones in WordPress. Some of them are working and some not (meaning it serves up the “old” location). I have the standard “pretty permalinks” mod_rewrite section in the file and then all the 301’s.
So, the ones that have an original location that are listed like a directory (re-written index.php) work and the ones that have an explicitly named php file do not. Examples:
This works:
Redirect 301 /about/ http://deanchiropractic.com/about-us/
This does (still serves dr-jon.php):
Redirect 301 /about/dr-jon.php http://deanchiropractic.com/about-us/dr-jon-dean/
I have tried changing the order around, tried having the 301s before and after the mod-rewrite section, tried with and without a DirectoryIndex line. I’ve also verified that i am editing the .htaccess in the webserver root.
I’d rather get my .htaccess working than put php to do the 301 Redirects in all the files that aren’t redirecting (I have tried, and verified that using one file).
Here is the entire thing for reference:
DirectoryIndex index.php index.html
Redirect 301 /about/dr-dean.php http://deanchiropractic.com/about-us/christophe-dean-dc/
Redirect 301 /about/dr-jon.php http://deanchiropractic.com/about-us/dr-jon-dean/
Redirect 301 /techniques/activator.php http://deanchiropractic.com/chiropractic-techniques/activator-method/
Redirect 301 /techniques/cox-technique.php http://deanchiropractic.com/chiropractic-techniques/cox-technique/
Redirect 301 /techniques/active-release.php http://deanchiropractic.com/chiropractic-techniques/active-release-technique/
Redirect 301 /community/dinner-talk.php http://deanchiropractic.com/get-healthy/
Redirect 301 /community/refer.php http://deanchiropractic.com/get-healthy/
Redirect 301 /resources/forms.php http://deanchiropractic.com/forms/
Redirect 301 /resources/faq.php http://deanchiropractic.com/faq/
Redirect 301 /resources/articles/low-back-pain-relief.php http://deanchiropractic.com/low-back-pain-relief/
Redirect 301 /resources/articles/about-the-activator-method.php http://deanchiropractic.com/achieve-wellness-with-the-activator-method/
Redirect 301 /resources/articles/spinal-disc-treatment.php http://deanchiropractic.com/spinal-disc-treatment/
Redirect 301 /resources/articles/headache-relief-benefits.php http://deanchiropractic.com/headache-relief/
Redirect 301 /resources/articles/carpal-tunnel-relief.php http://deanchiropractic.com/carpal-tunnel-relief/
Redirect 301 /resources/articles/neck-pain-relief.php http://deanchiropractic.com/neck-pain-relief/
Redirect 301 /testimonials.php http://deanchiropractic.com/reviews/
Redirect 301 /contact.php http://deanchiropractic.com/contact-us/
Redirect 301 /about/ http://deanchiropractic.com/about-us/
Redirect 301 /techniques/ http://deanchiropractic.com/chiropractic-techniques/
Redirect 301 /community/ http://deanchiropractic.com/get-healthy/
Redirect 301 /resources/ http://deanchiropractic.com/forms/
Redirect 301 /resources/articles/ http://deanchiropractic.com/category/articles/
# 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
I’ve searched wide, and on this site and can’t find a match for my exact problem…though I’ve learned a lot about .htaccess in the process (still a n00b tho). Thanks….
It’s possible that mod_alias and mod_rewrite are interferring with each other because they both get applied to the same URL in the processing pipeline. In this case, it may be that the URI is changed and a redirection is flagged by mod_alias (via the
Redirect
directive) but then mod_rewrite does its thing and rewrites the URI to get routed throughindex.php
, but the URI is flagged for a redirect so at the end of the pipeline, you have a mangled URI that gets sent as a redirect. You can avoid this by sticking with just mod_rewrite and using theL
flag so the wordpress rules don’t get applied:etc…