Looking for some help adding a 301 redirect for my Site
-
Hi there,
I am trying to eliminate the 'www' using a 301 redirect script as I have duplicate page titles for both versions (with and without the 'www')
I checked the page authority and found the pages without the 'www' to be ranked higher. For this reason I believe it would be wise to go for this option.
I have an .htaccess file, all I need is the code and I should be ok
Thanks!
-
I never had any issues with it without the nocase flag but it couldn't hurt
-
`Is that right? Should it not be` RewriteCond %{HTTP_HOST} ^www\.domain\.com [NC] RewriteRule ^(.*)$ http://domain.com/$1 [L,R=301] or even RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] RewriteRule ^(.*)$ http://%1/$1 [L,R=301] To be fair, I think all three of these will work.
-
Thanks a lot! Worked right away!
-
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.domain.com
RewriteRule (.*) http://domain.com/$1 [R=301,L]
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
-
.aspx 301 redirects on Business Catalyst
Hi I am have moved my website from .aspx to business catalyst. I have found out (when the site already migrated!) that Business Catalyst does not support .aspx 301 redirects. On a previous post from 2012 (https://moz.com/community/q/aspx-files-will-simply-not-work-as-redirects)Â , someone has recommended a java script re direct. I have tried this but google search console is classing this as a 404 resulting in no link juice and my website dropping pages on google. I have tried to do 301 redirects at my server level but wont work. Anyone know a solution? Thanks in advance Keith
Technical SEO | | EntertainmentIdeas0 -
301 Redirects in subfolders
Hi, we're making our site into a static site but I would like to transfer the Google juice. Most of the links and database exist on subfolders though. Could I simply do 301 redirects on the subfolders and retain the value or does it have to be on the full domain?
Technical SEO | | Therealmattyd0 -
301 Redirects on Large Real Estate Website
Hi guys,We are about to move over to a new website and need advice on handling the 301 redirects.We have a large real estate website with around 12,000 pages, a lot of these are properties (about 10,000)On our old website, the url structure for each property is as follows -domainname.com/property/view?property=14863on our new site, the url structure isdomainname.com/properties/view/6137The property ID number is always different from old site to new. The way we see it, we have two options. a.) a manual redirect of each and every property url. A very very long jobb.) a folder level redirect, so redirect the 'property' folder on the old site into the 'properties' folder on new. The con with this one is we are not sure if this is the best route to take, if it is how we would go about it?Some advice would be really appreciated guys. I know there are some hyper intelligent SEO's in here and we need to make sure we handle this right!Many thanks in advance.Mark
Technical SEO | | Nextman0 -
Does any one have experience with SEO and .NET using 301 redirects?
A while ago I altered some of the URL's of my website. Google now thinks that I have two duplicate pages (duplicate content), I have asked my third party web developers (Who use .NET and a custom built CMS system) to simply 301 redirect the old URL to the other. However, my web developers say the following: "Solving the problems by 301 permanent re directs are out of the question as this would create infinite loops. Likely to bring down our server." They also wont do a canonical, as they say there is only one page (but two URLs) Firstly, has any one heard of this before and do they think this is true? Also, does anyone have an alternative method of getting rid of the old URL? Any thoughts would be much appreciated.
Technical SEO | | CoGri0 -
Just noindexed and redirected junk from my site. Now what?
Hi to all! I've just finished 301 redirecting some pages and "noindex - follow" some other. I have to add a lot of canonicals yet, but this is a start. Now how I check the results? Should I wait a week or so to see if something improves? How long does it takes for Google to remove the pages I've just redirected and noindexed? My site is crawled every day (as all sites I guess). Thanks!
Technical SEO | | enriquef0 -
301 redirecting a mobile site.
Is it possible to selectively 301 redirect mobile/tablet user agents and google robots from the desktop version of a website to a mobile site? Would this preserve the SEO for the desktop website while optimizing the mobile/tablet site for mobile SEO?
Technical SEO | | inc.com0 -
301 help, whats the best way
Hi all right now i have 301 redirects setup in my htaccess file i recently redesigned our site so i have been redirecting all the old urls to the new ones. I saw a post about having all your urls the same format, so i updated my htaccess file to redirect all urls from http://www.mysite.com/food to http://www.mysite.com/food/ (added a forward slash). Now on my latest seo crawl i see all my site urls, redirecting to the forward slash url. am i doing this right, thanks will
Technical SEO | | Will_Craig0 -
Trailing slash 301 redirect code
Hi, I have code for redirecting trailing slash to non-trailing slash, which works fine: RewriteCond %{HTTP_HOST} !^.yourdomain.co.uk$ [NC]RewriteRule ^(.+)/$ http://%{HTTP_HOST}/$1 [R=301,L] (got code from http://googlewebmastercentral.blogspot.com/2010/04/to-slash-or-not-to-slash.html) But I cant find a code for redirecting to the trailing slash version anywhere, and I cant modify the above code myself. Can someone help resolve this issue please, or point me to a resource. Thanks very much James
Technical SEO | | jamesjackson0