Question

I'm trying to implement 301 re-directs on my self-hosted WordPress blog.

I have tried to do this through the .htaccess file that includes the standard mod_rewrite script for Apache.

I have also tried to do this through GoDaddy's 301 re-direct tool.

Further, I've also tried using the usually reliable Simply 301 Redirects for WordPress plugin.

None of the above work.

The 301 re-direct for Apache format that I'm using in the .htaccess is:

RewriteRule ^/blog/example-post.html? /blog/example-post/ [R=301,L,NC]
RewriteRule ^/blog/another-post? /blog/another-post-with-new-url/ [R=301,L,NC]

As you can see, the blog sits on /blog/. There is another .htaccess file in the root containing the following:

rewriteengine on


<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Expires "Wed, 1 Jan 2020 20:00:00 GMT"
</FilesMatch>
<ifmodule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript
</ifmodule>
rewritecond %{HTTP_HOST} ^mywebsite.com
rewriterule (.*) http://www.mywebsite.com/$1 [R=301,L]
rewritecond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.php\ HTTP/
rewriterule ^(.*)index\.php$ /$1 [R=301,L]
rewritecond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index-cc\.php\ HTTP/
rewriterule ^(.*)index-cc\.php$ /$1 [R=301,L]
rewritecond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.html\ HTTP/
rewriterule ^(.*)index\.html$ /$1 [R=301,L]
rewritecond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index2\.html\ HTTP/
rewriterule ^(.*)index2\.html$ /$1 [R=301,L]
rewritecond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index_OLD\.html\ HTTP/
rewriterule ^(.*)index_OLD\.html$ /$1 [R=301,L]

I deleted this from the .htaccess temporarily to see if there was any conflict with the WordPress .htaccess file. This didn't appear to be the case.

I also inserted the re-directs I used in WordPress into the root .htaccess file, but again, this didn't solve the problem.

I have run out of options that I am aware of. Are there any other suggestions for what I could implement to solve this?

No correct solution

OTHER TIPS

You need to remove the leading slashes in your htaccess file's rules:

RewriteRule ^blog/example-post.html /blog/example-post/ [R=301,L,NC]
RewriteRule ^blog/another-post /blog/another-post-with-new-url/ [R=301,L,NC]

And get rid of the ? part.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top