Home 301 redirect old indexed URLs
Reply: 1

301 redirect old indexed URLs

jpann
1#
jpann Published in 2011-12-25 06:33:01Z

My client had a wordpress blog at "domain.com/blog" with permalink structure "?p=page-id". I archived this site at "v1.domain.com". everything works fine.

I create the new wordpress blog at "domain.com/blog" with permalink structure "/year/month/postname". still, everything fine.

I did a google search and found the old blog posts. they link to "domain.com/blog?p=page-id" and when single.php tries to open these files the loop goes crazy.

here is an example: http://davidapuzzo.com/blog/?p=1821

if you add "v1" to the beginning of the domain, you will see where the post actually is:

http://v1.davidapuzzo.com/blog/?p=1821

I understand It would be a 301 redirect that finds all "http://domain.com/blog?p=page-id" URLs and redirect/prepends them with "v1.domain.com..." ? I just dont know how to write the reg expression and where to add it within my wordpress .htaccess file.

I've included my wordpress .htaccess below:

# 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

My client has some deep indexed URLs, as you can see above with the Connecticut Weatherman/Meterologist. that post is the 6th result on the first page of results for a search on his name.

The new site was launched today and any help would be greatly appreciated. Thanks!

Virendra
2#
Virendra Reply to 2011-12-26 07:27:56Z

Try this rule:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^davidapuzzo.com
RewriteCond %{QUERY_STRING} ^p= [NC]
RewriteRule blog/(.*)$ http://v1.davidapuzzo.com/blog/ [L,R=301]

To redirect all URLs containing a query string to the sub-domain use the following. This will redirect all URL containing '?'.

RewriteEngine On
RewriteCond %{HTTP_HOST} ^davidapuzzo.com
RewriteCond %{QUERY_STRING} .
RewriteRule blog/(.*)$ http://v1.davidapuzzo.com/blog/ [L,R=301]
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.620006 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO