Redirects for new website
-
Hi Moz community,
I'm a fairly new SEO Specialist with a brand new website. We initially had a very basic holding website until the fully functional website was completed. I have to do some redirects as we have both .html and .php files & we don't want to lose SEO value for specific pages (like the index, news, etc). I also want to redirect from a www url to a non-www url.I am trying to accomplish redirects with the following code:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.mywebsite.com [NC]
RewriteRule (.*) http://mywebsite.com/$1 [R=301,L]RedirectMatch 301 /index.html (.*).(php|html) http://mywebsite.com/index.php
RedirectMatch 301 /cupcakes-slideshow/glutenfree-slideshow.html (.*).(php|html) http://mywebsite.com/gluten-and-glutenfree.php
RedirectMatch 301 /press.html (.*).(php|html) http://mywebsite.com/news-and-reviews.php
Please let me know if I am on the right track. Thanks so much in advance!
-
Thanks so much Jeff. I will try the options you suggested.
-
Yes, there are two main ways to do something like this.
My recommendation would be based on how many actual pages you need to redirect, and if you want to redirect everything, or if you want to redirect only a few pages here and there.
Option 1. Redirect everything using programming.
The first way, is to use a rewrite rule like this:
RewriteRule ^/blog/(.*)$ http://blog.subdomain.com/$1 [R=301,L]... that will redirect things programatically. Your syntax seems to be okay, but I'd test it out to make sure it's working properly.
Advantages: One or two lines, and you're done!
Disadvantages: You are redirecting everything, and you can't test each and every line easily.Option 2. Belt and Suspenders Method.
The second way is what I like to call the belt and suspenders method. It is not elegant. But the theory is that if you wear both suspenders and a belt, chances are good that you won't have your pants fall down.
This option creates a rewrite rule for each page on the site that is added to your .htaccess file.
What's nice about this is that you can easily create these redirects, without programming, just using a sitemap page.
I wrote a long article over on this site:
http://www.advancedwebranking.com/blog/how-to-create-301-redirects-from-sitemap/... that shows how to create these redirects quickly, without any programming (just through Excel and a text editor).
Option 3. Use the rewrite rule, but use the method in option 2 to create a list of all of the pages that need to be redirected.
If you'd rather, you could also use the method for creating a list of all of the pages that need to be redirected, and then use a 301 redirect checking script (there are a lot of free ones out there, just Google it), and then test if your method is working properly.
Hope this helps!
- Jeff
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
-
301 Redirects Showing As 307 Redirects
Hi, Our clients are adamant that they have set up 301 permanent redirects on their websites, but when we check using Screaming Frog and various online HTTP status code checkers they are showing as 307 temporary redirects. Examples;
Technical SEO | | Webpresence
http://www.lifestylelifts.co.uk/home-lifts/
http://www.terrylifts.co.uk/ Again, the client says they are seeing 301 redirects. Why are we seeing 307's? Who is right? Very puzzling, any theories would be very much appreciated 🙂 Thanks in advance. Lee.0 -
Redirect and ranking issue
Hi there - was wondering whether someone might be able to help. For a period of a day and a half, all the traffic to our website's blog articles were mistakenly being redirected to our homepage. A number of these articles ranked in the top 5 in Google worldwide for their targeted keywords, so this was a considerable amount of organic traffic that was instantly being redirected. It was a strange site glitch and our web team rectified the error, but now all these articles have disappeared from Google rankings (not visible anywhere in the first five pages). I'm presuming this must be linked to this redirect issue - we've been advised to wait and see whether Google restores these rankings, but I'm still concerned as to whether this represents a more serious problem? We have re-indexed the pages we are most concerned about, but am not sure whether there is anything else obvious we should think to do. If anyone has any thoughts, I'd be happy to hear them!
Technical SEO | | rwat0 -
To many 301 redirects
Hi, Is there anything wrong with over 100 301 reditects on my wordpress website and how do you go about redirecting a 301 again for example abc.com redirects to bca.com now i want to redirect bca.com to ert.com any problems with this setup? Regards
Technical SEO | | ReSEOlve0 -
SSL redirect issue
Hi guys, I have a site that has some internal pages with SSL. Recently i noticed that if i put https://mydomain.com, this URL is accessible but all the design is messed up. My site is on wordpress and i use "redirection" plugin for all the 301 redirect. So i decided to add a new 301 redirect from https://mydomain.com to my actual URL version of home page http://mydomain.com. After doing that, my home page doesn't load at all. Does anybody know what happens? Thank you for advice!
Technical SEO | | odmsoft0 -
Website Down
Hello guys, My website hasn't been reachable for couple of hours today and I can't really understand why as no links have been built, all the best practices have been followed regarding on page optimization. I also checked google webmaster tools and there are no warning messages, crawl problems or anything so I don't understand why this has happened. Now for some reason the website is up and running again.
Technical SEO | | PremioOscar1 -
Redirecting the .com of our site
Hey guys, A company I consult for has a different site for its users depending on the geography. Example: When a visitor goes to www.company.com if the user is from the EU, it gets redirected to http://eu.company.com If the user is from the US, it goes to http://us.company.com And so on. I have two questions: Does having a redirect on the .com will influence rankings on each specific sub-site? I suspect it will affect the .com since it will simply not get indexed but not sure if affects the sub domains. The content on this sub-sites are not different (I´m still trying to figure out why they are using the sub-domains). Will they get penalized for duplicate content? Thanks!
Technical SEO | | FDSConsulting0 -
301 Redirect
Hi there, We are re-branding & re-structuring our website, there will be quite a number of 301 re-directs, possibly hundreds. The question is: Should i wait until the re-branding has been completed and do al the 301's in one go?, or should I try and do 301's as i go along? Kind Regards
Technical SEO | | Paul780 -
Would moving a large part of our website onto a separate website be SEO suicide?
Hello, Our website currently has what I would call educational and sales pages - which sells our services and also a techy section for the developer community. The developer pages on the website have some of the highest authority pages that we have and equates for about 50% of the content. It has been proposed to move the developer pages onto their own domain - away from the main website. Now, would this crush a lot of the SEO benefit that we have on our main site? Does anyone know of a workable solution that would help retain the SEO. Would linking to our main site from the developer site help? It would be great to hear what people think, Thanks,
Technical SEO | | esendex0