I currently have an Expression Engine blog which I am going to move over to WordPress, the current url structure is /blog/comments/page-title
I have imported the posts into WordPress and I’m going to keep the same page title’s for the pretty urls but just want the address to be /page-title
the WordPress htaccess file is as follows
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
can anybody tell me how I do this additional redirect in this block? Also will this totally ensure that search engine indexing won’t be affected as it has been running for 4 years and I have over 1700 blog posts currently indexed.
Put this before your WordPress rules in your .htaccess file:
RedirectMatch ^/blog/comments/(.+)$ /$1 [R=301]
This will redirect
http://yourdomain.com/blog/comments/my-post
tohttp://yourdomain.com/my-post
, and tell search engines that the redirect is permanent.One note: WordPress discourages the use of
/%postname%/
as a permalink structure as it adds many more queries to determine the content to load. From http://codex.wordpress.org/Using_Permalinks:So I’d suggest instead using something like
/blog/%postname%
instead, in which case your rule would look like:RedirectMatch ^/blog/comments/(.+)$ /blog/$1 [R=301]