How to write 301 redirects in WordPress
-
I've successfully migrated new site to new domain (www.cmsearchmarketing.com)
But I cannot get 301 redirects for pages and blog posts to redirect from the old domain (www.creativemindsearchmarketing.com).
And it's my understanding I need to do a 301 for each page to maintain SEO.
Here's what I've tried:
RewriteCond %{QUERY_STRING} ^p=975$RewriteRule ^index.php$ http://www.cmsearchmarketing.com/top-5-questions-to-ask-an-seo-firm-before-signing-up/? [R=301,L]
BEGIN WordPress<ifmodule mod_rewrite.c="">RewriteEngine OnRewriteBase /RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule . /index.php [L]</ifmodule># END WordPress
#AND ALSO#
Use PHP5 Single php.ini as defaultAddHandler application/x-httpd-php5s .php
BEGIN WordPress<ifmodule mod_rewrite.c="">RewriteEngine OnRewriteBase /RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule . /index.php [L]</ifmodule># END WordPress
redirect 301 /top-5-questions-to-ask-an-seo-firm-before-signing-up http://www.cmsearchmarketing.com/top-5-questions-to-ask-an-seo-firm-before-signing-up/
Any suggestions would be appreciated.
_Cindy
P.S. Maybe some other issues are in the way:
--Old site is WP-Remix theme no longer supported, and latest WP version is 2.9.1
-- Old domain (www.creativemindsearchmarketing.com) is the primary account on BlueHost …and the new domain (www.cmsearchmarketing.com) is an addon, so the new domain's directory is within root of old domain.
-- in root domain of old site there are other "handler files" that also have base file rewrites, if this is an issue:
name of this file in root directory is:
.htaccess.addHandlerBak-FrontPage-
<limit get="" post="">order deny,allowdeny from allallow from all</limit><limit put="" delete="">order deny,allowdeny from all</limit>AuthUserFile /home/creatjo7/public_html/_vti_pvt/service.pwdAuthGroupFile /home/creatjo7/public_html/_vti_pvt/service.grp# BEGIN WordPress<ifmodule mod_rewrite.c="">RewriteEngine OnRewriteBase /RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule . /index.php [L]</ifmodule>
END WordPressAuthName creativemindsearchmarketing.comIndexIgnore .htaccess /.?? *~ *# /HEADER /README /_vti
-
OK, so simple 301 redirects seem to be working out fine.
But having a thing for a puzzle, and thus far learning more about htaccess, I am wondering why a simple rewrite... or "redirect" rule would not work. Like this:
RewriteRule ^(./blog)$ http://cmsearchmarketing.com/blog$1.php [R=301,NC]
or this
RewriteRule ^./blog$ http://www.cmsearchmarketing.com/blog [R=301,NC]
(...and this goes into the old site htaccess with the old domain name, NOT the new site with the new domain name; and the new site basically has all new page names.)
Where in the htaccess file would it go... after the WP permalink rule - considering I am using permalinks on the site and writing the rules with the permalink structure?
Can I write a rule such as this and redirect to another domain all together?
When would I use [L] for last rule?
And what's the difference in a rewrite and a redirect?
OK, if anyone is pursuing and can help I would appreciate.
Thank you very much._Cindy
-
Sorry, try that link again (I've edited it)
-
Didn't understand the link you gave...
-
Hi Cindy,
You can install the plugin on your current setup, and it should work, if by chance it doesnt work, you can download the older versions here which are supported in 2.9.1
This plugin allows you to 301 redirect from anywhere on your site to any external link you want
-
You should be able to do something like this: http://screencast.com/t/1kU7rKwiC
-
So is the redirection plugin installed on the old site (that's a different domain name), and can the target url be an external link?
The source URL cannot be an external link, right?
Cindy
-
Thank you for answering.
None of the pages are the same name on new site as on the old site.
However, the blog posts are the same. And if i could use a redirect for all pages on blog that would help.
But when I use the cpanel wildcard, or rules to the htaccess file, I do not get one page corresponding to the new page, - all old blog posts go to the home page.
_Cindy
-
Cindy as long as your categories and file names are the same, you can just put in 1 (one) wild card redirect that will redirect everything from your old domain to the same file name on your new domain. i.e. olddomain.com/seo/goodseo.html will redirect to newdomian.com/se/goodseo
And, the easiest way to do this is from your servers Cpanel. Go into the cpanel, look for redirect, tell it the old domain and the new domain and tell it to use "wild card" for redirection.
-
Thanks for your reply.
The old site theme isn't supported anymore, cannot update WP beyond 2.9.1.
Does this simple 301 redirect plugin need to be on old site or new?
So if old domain name is different than new domain name, can I use this plugin?
_Cindy
-
I recommend Redirection – it's the most popular plugin out there. I use it on a number of sites and works great.
-
Is the old site in WordPress? Try Simple 301 Redirects or a similar plugin to 301 individual pages/posts.
Browse Questions
Explore more categories
-
Moz Tools
Chat with the community about the Moz tools.
-
SEO Tactics
Discuss the SEO process with fellow marketers
-
Community
Discuss industry events, jobs, and news!
-
Digital Marketing
Chat about tactics outside of SEO
-
Research & Trends
Dive into research and trends in the search industry.
-
Support
Connect on product support and feature requests.
Related Questions
-
Wordpress Redirect Loop on domain name
Hi hopefully someone can help - pulling my hair out - can't seem to find where this redirect is coming from. Curently there is a redirect from http://bimi to https://bimi then to our real domain https://www.bimi But I can't find it - I have checked through hta access file, through YOAST redirects - any suggestions from anyone who has has this before in wordpress? | http://bimi.co | 23 | 0 | 3 | |
Technical SEO | | KellyDSD86
| | | Associated Pages | |
| | | https://bimi.co/ | 23 | 1 | | |
| | | Office Furniture Online | The UK's major Office Furniture Retailer | BiMi.cohttps://www.bimi.co/ | HTA access says the following - I have googled to see whether its causing it but none the wiser! BEGIN LSCACHE LITESPEED WP CACHE PLUGIN - Do not edit the contents of this block! <ifmodule litespeed="">RewriteEngine on
CacheLookup on
RewriteRule .* - [E=Cache-Control:no-autoflush]
RewriteRule ^min/\w+.(css|js) - [E=cache-control:no-vary] marker CACHE RESOURCE start RewriteRule wp-content/./[^/](responsive|css|js|dynamic|loader|fonts).php - [E=cache-control:max-age=3600] marker CACHE RESOURCE end marker FAVICON start RewriteRule favicon.ico$ - [E=cache-control:max-age=86400] marker FAVICON end ###</ifmodule> LITESPEED WP CACHE PLUGIN - Do not edit the contents of this block! END LSCACHE BEGIN NON_LSCACHE LITESPEED WP CACHE PLUGIN - Do not edit the contents of this block! marker MINIFY start <ifmodule mod_rewrite.c="">RewriteEngine on
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} ^(.*)/min/(\w+).(css|js)$
RewriteCond %1/wp-content/cache/$2/$1.$2 -f
RewriteRule min/(\w+).(css|js) wp-content/cache/$2/$1.$2 [L]</ifmodule> marker MINIFY end LITESPEED WP CACHE PLUGIN - Do not edit the contents of this block! END NON_LSCACHE 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 WordPress0 -
Is there a way to set up 301 auto redirects from 404s
some of our pages under a specific website section gets deleted from another data source and we want to resolve the problem of 404s can we set up automated 301 redirects to the main page as soon as one of these pages are deleted
Technical SEO | | lina_digital2 -
301 redirection for e-commerce website
Hi moz community, I am the web agency for a e-commerce website. Its current domain is https://www.liquorland.co.nz but now all the e-commerce part will be moved to a sub-domain https://shop.liquorland.co.nz. There are thousands of e-commerce current being indexed in Google (i.e., 15,500) plus they also have a mobile version of the page like /mobile/default.aspx. Is it necessary to 301 redirect all the pages? We are afraid it may slow down the website because the request will go through thousands of filters. Is it OK to just redirect the main categories? Many thanks in advance.
Technical SEO | | russellbrown0 -
Should I resubmit a 301 redirected domain in Webmaster Tools
We recently switched over a .com site to a new server. The .com site had a .co.uk domain redirecting to it previously, but when the switchover happened, the .co.uk was forgotten about. We have now realised what has happened, but not before taking a hit with our rankings. The .co.uk is still indexed in Google and now that we have sorted the redirects they are pointing to the right places. My question now; is there anything further I need to do? I know that the .co.uk will soon be removed from the SERPs, but I just want to make sure I haven't forgotten anything.
Technical SEO | | Ben_Malkin_Develo0 -
Soft 404's on a 301 Redirect...Why?
So we launched a site about a month ago. Our old site had an extensive library of health content that went away with the relaunch. We redirected this entire section of the site to the new education materials, but we've yet to see this reflected in the index or in GWT. In fact, we're getting close to 500 soft 404's in GWT. Our development team confirmed for me that the 301 redirect is configured correctly. Is it just a waiting game at this point or is there something I might be missing? Any help is appreciated. Thanks!
Technical SEO | | MJTrevens0 -
Product Level 301 Redirects Best Practice
When creating a 301 mapping file for product pages, what is best practice
Technical SEO | | Bucktown
for which version of the URL to redirect to? Base directory or one
subdirectory/category path. Example Old URL: www.example.com/clothing/pants/blue-pants-123 Which of the following should be the new target URL: www.example.com/apparel/pants/blue-pants-123 www.example.com/apparel/blue-apparel/blue-pants-123 www.example.com/apparel/collections/spring-collection/blue-pants-123 www.example.com/blue-pants-123 This is assuming the canonical tag will be www.example.com/blue-pants-123. Also, if www.example.com/blue-pants-123 cannot be reached via site
navigation would it be detrimental to make that the target URL if Google
cannot crawl that naturally? Thanks0 -
How to create a delayed 301 redirect that still passes juice?
My company is merging one of our sites into another site. At first I was just going to create a 301 redirect from domainA.com to domainB.com but we decided that would be too confusing for customers expecting to see domainA.com so we want to create a page that says something like "We've moved. please visit domainB.com or be redirected after 10 seconds". My question is, how do I create a redirect that has a delay and will this still pass the same amount of juice that a regular 301 redirect would? I've heard that meta refreshes are considered spammy by Google.
Technical SEO | | bewoldt0 -
301 redirect Issues
my clients site is www.greenbayharvest.co.uk When you enter that URL it redirects to www.greenbayharvest.co.uk/shop, dont ask why, thats the way they set it up and thats what im stuck with. So, how do i resolve the 301 issue here. we want all things to point to www.greenbayharvest.co.uk, in terms of SEO but does the fact that there is a redirect going to /shop make this an issue? we appear to have: www.greenbayharvest.co.uk/shop www.greenbayharvest.co.uk greenbayharvest.co.uk greenbayharvest.co.uk/shop all these URL's go to the same same page so what is the best way to correct this? thanks for any help on this Lee
Technical SEO | | IPIM0