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
-
Redirect chain error free htaccess code for website
i want to redirect domain, example.com to https://www.example.com, is anyone can help me to provide redirect chain error free ht-access code. I implemented this htaccess code on the website and mhy site show on the moz redirect chain error RewriteCond %{HTTP_HOST} !=""
Technical SEO | | truehab
RewriteCond %{THE_REQUEST} ^[A-Z]+\s//+(.)\sHTTP/[0-9.]+$ [OR]
RewriteCond %{THE_REQUEST} ^[A-Z]+\s(./)/+\sHTTP/[0-9.]+$
RewriteRule .* http://%{HTTP_HOST}/%1 [R=301,L]0 -
I have a question about the impact of a root domain redirect on site-wide redirects and slugs.
I have a question about the impact (if any) of site-wide redirects for DNS/hosting change purposes. I am preparing to redirect the domain for a site I manage from https://siteImanage.com to https://www.siteImanage.com. Traffic to the site currently redirects in reverse, from https://www.siteImanage.com to https://siteImanage.com. Based on my research, I understand that making this change should not affect the site’s excellent SEO as long as my canonical tags are updated and a 301 redirect is in place. But I wanted to make sure there wasn’t a potential consequence of this switch I’m not considering. Because this redirect lives at the root of all the site’s slugs and existing redirects, will it technically produce a redirect chain or a redirect loop? If it does, is that problematic? Thanks for your input!
Technical SEO | | mollykathariner_ms0 -
URL Redirect
Hi All, So we have employees who can own their own domains for business, however, one employee has a domain that links back to our main site, but when it does, the URL and Page title of our main site, still say his own domain. IE: www.johndoe.com links to www.mysite.com except the url and itle still say www.johndoe.com What are the implications of this? Thank you
Technical SEO | | PeteEllard0 -
How to Handle Website Merge?
We are a law firm and have another law firm merging into ours. Our branding will remain the same, but I am trying to figure out how to best handle their website transition. Should we link it to ours (although their PR & page authority are not significant) or should I map each page to ours with similar content with a redirect? MY main concerns are not damaging our website's SEO by doing something search engine's would frown on and also to try to take advantage of any organic traffic or referral traffic. Or maybe some combination - link homepage with added verbage that attorney is now with our firm and a link and redirect the sub-pages? I look forward to thoughts from anyone who might have experience with this type to issue. Thanks in advance! JulieHow t
Technical SEO | | JulieALS0 -
My beta site (beta.website.com) has been inadvertently indexed. Its cached pages are taking traffic away from our real website (website.com). Should I just "NO INDEX" the entire beta site and if so, what's the best way to do this? Please advise.
My beta site (beta.website.com) has been inadvertently indexed. Its cached pages are taking traffic away from our real website (website.com). Should I just "NO INDEX" the entire beta site and if so, what's the best way to do this? Are there any other precautions I should be taking? Please advise.
Technical SEO | | BVREID0 -
301 redirects
Hi, I am a working on a new web site, and I want to redirect all the urls of another site (on a different host) to this one. According to both hosts it is "impossible" to do this for all urls. I don't believe that to be the case, but how do I do this? And, should both sites be hosted on the same server first?
Technical SEO | | vibelingo0 -
To 301 redirect or not to 301 redirect? duplicate content problem www.domain.com and www.domain.com/en/
Hello, If your website is getting flagged for duplicate content from your main domain www.domain.com and your multilingual english domain www.domain.com/en/ is it wise to 301 redirect the english multilingual website to the main site? Please advise. We've recently installed the joomish component to one of our joomla websites in an effort to streamline a spanish translation of the website. The translation was a success and the new spanish webpages were indexed but unfortunately one of the web developers enabled the english part of the component and some english webpages were also indexed under the multilingual english domain www.domain.com/en/ and that flagged us for duplicate content. I added a 301 redirect to redirect all visitors from the www.domain/en/ webpages to the main www.domain.com/ webpages. But is that the proper way of handling this problem? Please advise.
Technical SEO | | Chris-CA0 -
Removing pages from website
Hello all, I am fairly new to the SEOmoz community. But i am working for a company which organizes exhibitons, events and training in Holland. A lot of these events are only given ones ore twice and then we do not organise them any more because they are no longer relevant. Every event has its own few webpages which provide information about the event and are being indexed by Google. In the past we did not remove any of these events. I was looking in the CMS and saw a lot of events of 2008 and older which are being indexed. To clean the website and the CMS i am thinking of removing these pages of old events. The risk is that these pages have some links to them and are getting some traffic, so if i remove them there is a risk of losing traffic and rankings. What would be the wise thing to do? Make a folder with archive or something? Regards, Ruud
Technical SEO | | RuudHeijnen0