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.
Got a burning SEO question?
Subscribe to Moz Pro to gain full access to Q&A, answer questions, and ask your own.
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
-
Can i do 301 redirect
So this is what im doing, 301 redirect to my site/allen-webdesign points to main domain Allen is the city i have a page called local-webdesign with all the cities. Will this improve my ranking or should i stop?
Technical SEO | | jsdfw0 -
How do I redirect the Author archive page in Wordpress?
If you do a search for my name on Google, the first result is the author archive page of my Wordpress blog. I would like to redirect the author page to my "about me" page but cannot add a 301 as the author page is created dynamically in Wordpress. Anyone know how I can do this?
Technical SEO | | richdan0 -
How best to fix 301 redirect problems
Hi all Wondering if anyone could help out with this one. Roger Bot crawler has just performed it's weekly error crawl on my site and I appear to have 18,613 temp redirect problems!! Rather, the same 1 problem 18,613 times. My site is a magento store and the errors it is giving me is due to the wishlist feature on the site. For example, it is trying to crawl links such as index.php/wishlist/index/add/product/29416/form_key/DBDSNAJOfP2YGgfW (which would normally add the item to one's wishlist). However, because Roger isn't logged into the website it means that all these requests are being sent to the login url with the page title of Please Enable Cookies. Would the best way to fix this be to enable wishlists for guests? I would rather not do that but cannot think of another way of fixing it. Any other Magento people come across this issue? Thanks, Carl
Technical SEO | | daedriccarl0 -
Remove html file extension and 301 redirects
Hi Recently I ask for some work done on my website from a company, but I am not sure what they've done is right.
Technical SEO | | ulefos
What I wanted was html file extensions to be removed like
/ash-logs.html to /ash-logs
also the index.html to www.timports.co.uk
I have done a crawl diagnostics and have duplicate page content and 32 page title duplicates. This is so doing my head in please help This is what is in the .htaccess file <ifmodule pagespeed_module="">ModPagespeed on
ModPagespeedEnableFilters extend_cache,combine_css, collapse_whitespace,move_css_to_head, remove_comments</ifmodule> <ifmodule mod_headers.c="">Header set Connection keep-alive</ifmodule> <ifmodule mod_rewrite.c="">Options +FollowSymLinks -MultiViews</ifmodule> DirectoryIndex index.html RewriteEngine On
# Rewrite valid requests on .html files RewriteCond %{REQUEST_FILENAME}.html -f RewriteRule ^ %{REQUEST_URI}.html?rw=1 [L,QSA]
# Return 404 on direct requests against .html files RewriteCond %{REQUEST_URI} .html$
RewriteCond %{QUERY_STRING} !rw=1 [NC]
RewriteRule ^ - [R=404] AddCharset UTF-8 .html # <filesmatch “.(js|css|html|htm|php|xml|swf|flv|ashx)$”="">#SetOutputFilter DEFLATE #</filesmatch> <ifmodule mod_expires.c="">ExpiresActive On
ExpiresByType image/gif "access plus 1 years"
ExpiresByType image/jpeg "access plus 1 years"
ExpiresByType image/png "access plus 1 years"
ExpiresByType image/x-icon "access plus 1 years"
ExpiresByType image/jpg "access plus 1 years"
ExpiresByType text/css "access 1 years"
ExpiresByType text/x-javascript "access 1 years"
ExpiresByType application/javascript "access 1 years"
ExpiresByType image/x-icon "access 1 years"</ifmodule> <files 403.shtml="">order allow,deny allow from all</files> redirect 301 /PRODUCTS http://www.timports.co.uk/kiln-dried-logs
redirect 301 /kindling_firewood.html http://www.timports.co.uk/kindling-firewood.html
redirect 301 /about_us.html http://www.timports.co.uk/about-us.html
redirect 301 /log_delivery.html http://www.timports.co.uk/log-delivery.html redirect 301 /oak_boards_delivery.html http://www.timports.co.uk/oak-boards-delivery.html
redirect 301 /un_edged_oak_boards.html http://www.timports.co.uk/un-edged-oak-boards.html
redirect 301 /wholesale_logs.html http://www.timports.co.uk/wholesale-logs.html redirect 301 /privacy_policy.html http://www.timports.co.uk/privacy-policy.html redirect 301 /payment_failed.html http://www.timports.co.uk/payment-failed.html redirect 301 /payment_info.html http://www.timports.co.uk/payment-info.html1 -
Help writing a .htacess file with the correct 301 redirects
Hello I need help writing a .htaccess file that will do two things. URL match abc.com and www.abc.com to www.newabc.com except one subdomain was also changed www.abc.com/blog is now www.newabc.com/newblog everything after blog matches. Any help would greatly be appreciated. Thanks
Technical SEO | | chriistaylor0 -
Can you 301 redirect a page to an already existing/old page ?
If you delete a page (say a sub department/category page on an ecommerce store) should you 301 redirect its url to the nearest equivalent page still on the site or just delete and forget about it ? Generally should you try and 301 redirect any old pages your deleting if you can find suitable page with similar content to redirect to. Wont G consider it weird if you say a page has moved permenantly to such and such an address if that page/address existed before ? I presume its fine since say in the scenario of consolidating departments on your store you want to redirect the department page your going to delete to the existing pages/department you are consolidating old departments products into ?
Technical SEO | | Dan-Lawrence0 -
Can you do a 301 redirect without a hosting account?
Trying to retire domain1 and 301 it to domain2 - just don't want to get stuck having to pay the old hosting provider simply to serve a .htaccess file with the redirect rule.
Technical SEO | | TitanDigital0 -
301 Redirect with ASP (not .NET)
I'm looking to redirect non www to www and also .co.uk to .com. http://www.xxxxx.com is the intended target. http://xxxxx.com & http://www.xxxxx.co.uk & http://xxxxx.co.uk to redirect. I managed to do some of this but if I come through to a service page /services/cars.asp it redirects to the homepage. All I have so far is this code: <% If InStr(Request.ServerVariables("SERVER_NAME"),"www") = 0 ThenResponse.write "http://www." & Request.ServerVariables("HTTP_HOST") & Request.ServerVariables("URL") & "?" & Request.ServerVariables("QUERY_STRING")Response.EndEnd if %> What am I missing?
Technical SEO | | Hughescov0