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, Sitemaps and Indexing - How to hide redirected urls from search engines?
We have several pages in our site like this one, http://www.spectralink.com/solutions, which redirect to deeper page, http://www.spectralink.com/solutions/work-smarter-not-harder. Both urls are listed in the sitemap and both pages are being indexed. Should we remove those redirecting pages from the site map? Should we prevent the redirecting url from being indexed? If so, what's the best way to do that?
Technical SEO | | HeroDesignStudio0 -
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 -
Website Cached Version
Hi all Why my full content is not appearing in Text only version(cached version): http://webcache.googleusercontent.com/search?q=cache:zakoopi.com&es_sm=93&strip=1 Original website link: http://www.zakoopi.com/ How can I resolve this issue?
Technical SEO | | Obbserv0 -
Website cache?
Hi mozzers, I am conducting an audit and was looking at the cache version of it. The homepage is fine but all the other pages, I get a Google 404. I don't think this is normal. Can someone tell me more what could be the issue here? thanks
Technical SEO | | Ideas-Money-Art0 -
Importance of 301 Redirects
Hello, I have been brought in at the last minute to consult for an e-commerce client who is about to relaunch their website. The site currently receives 8000 visits a month, 3100 of which are from organic search. They have a few thousand product pages. The web development firm they are using is changing all of the old product page urls and using 'search engine friendly' urls for the new site, which is expected to launch in a few weeks. However, they did not/are not planning on including 301 redirects from the old URLs. Other than simply stating 'this will be bad for your SEO', what would be a correct way of explaining to the client how much of a problem it will be if their new site launches without 301s. For example, is this a big enough issue to delay the launch of the site / get in a contract dispute with the web developer?
Technical SEO | | stageagent0 -
Should I Do On Site Optimization For A Website That Will Get A New Design
Would it be wise for me to start implementing onsite optimization changes on a website, such as the changing urls, adding in keywords in meta tags, meta descriptions, etc if the website is about to get a totally new design. For example if I wanted to change the url structure and onsite optimization features would the changes still be on the new website.
Technical SEO | | TSpike10 -
Redirect questions
Hi! A client of mine have created a new site with a new URL structure which they launched the other day. They have done a 301 redirect on all pages on the old site to the start page on the new site. E.g:
Technical SEO | | lojdqvist
www.olddomain.com/subfolder1/index.html -> www.newdomain.com
www.olddomain.com/subfolder2/index.html -> www.newdomain.com I'm thinking of fixing this now so the redirect instead looks someting like this:
www.olddomain.com/subfolder1/index.html -> www.newdomain.com/newsubfolder1/index.html
www.olddomain.com/subfolder1/index.html -> www.newdomain.com/newsubfolder1/index.html Two questions: 1. Is it worth doing the latter kind of redirect in all cases (after all, it involves quite a lot more work compared to the first solution)? or do you recommend the first solution for all redirect projects?
2. Now that they have already done the first solution, is it at all worth amending this to the latter or is everything spoiled now that they have already gone ahead with the first solution? Many thanks in advance!0 -
301 Redirect Domain or 301 Redirect Domain + Interior Pages
Hello - My company acquired another company in our industry and our IT team immediately set up the acquired companies domain name as a an alias to our site. This created a duplicate version of our website under another domain name and Google started ranking interior pages from the aliased acquired site for several top keywords that were previously held by our real site. Should we 301 redirect just the top level domain name of the acquired site to the real site or 301 redirect the top level domain name and the interior pages on the acquired site to help ensure that our real domain will take back the rankings it once had? Thanks!
Technical SEO | | Room2140