What is the code to 301 http to www in htaccess file on unix server
-
i want to 301 my http home page to www on a linux server and all my other redirects are set up similar to this in my htaccess file:
redirect 301 /example-page.html http://www.example-page.html
how do I 301 redirect:
http://example.com to http://www.example.com
I've tried all kinds of code recommended for an htaccess file on a linux server and nothing seems to work.
Thanks for the help mozzers!
Ron
-
1st works fine for me....
Redirect 301 /tags/xp/ http://www.test.com/tags/windows-xp/
if it is not working there must be some other problem!
-
Hi Ron,
You will need to use URL rewrite and the following code:
RewriteEngine On
RewriteCond %{HTTP_HOST} !=www.example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]That will redirect any page/file on example.com/file to www.example.com/file with a 301 redirect.
Hope that helps!
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
-
Godaddy renewal discount codes
Hi, I purchase a lot of domains through godaddy. does anyone know of any source of renewal discount codes for domains with them?godadd
Web Design | | corn20150 -
Help with error: Not Found The requested URL /java/backlinker.php was not found on this server.
Hi all, We got this error for almost a month now. Until now we were outsourcing the webdesign and optimization, and now we are doing it in house, and the previous company did not gave us all the information we should know. And we've been trying to find this error and fix it with no result. Have you encounter this issue before? Did anyone found or knows a solution? Also would this affect our website in terms of SEO and in general. Would be very grateful to hear from you. Many thanks. Here is what appears on the bottom of the site( www.manvanlondon.co.uk) Not Found The requested URL /java/backlinker.php was not found on this server. <address>Apache/2.4.7 (Ubuntu) Server at 01adserver.com Port 80</address> <address> </address> <address> </address>
Web Design | | monicapopa0 -
Can Image File Names be Masked?
If we "mask" file names for our website but they are left their original name on the server, will Google notice this? Client wants to mask them in order to name them with keywords but not change on the actual server.
Web Design | | Atlanta-SMO0 -
Is it possible to redirect the main www. domain - but keep a subdomain active?
Hi Mozzers, Quick question, which I hope one of you can answer... Let's say I have a website (i) www.example.com and on that a subdomain exists, (ii) subdomain.example.com. Let's say I want to change my main domain from www.example.com to www.newwebsite.com. I'd 301 all content, use GWT to notify Google of a change of address etc etc. Having done that, is it still possible to keep the original subdomain active? So, even though www.example.com has been redirected / transferred to www.newwebsite.com, subdomain.example.com would still exist. If that is possible, what is the implication for Domain Authority? On the one hand, I have transferred the main site (so DA from that will transfer to the new site); but part of that root domain is still active. Make sense? Any answers? Thanks everyone...
Web Design | | edlondon0 -
Http://www.domain.com/services/city or http://www.domain.com/city
Hi, I have a website created on a WordPress Platform. My site is in the "Service" industry and we perform the same service for many different "cities." My question pertains to the Navigation Bar and SEO. Is it better to have a "Service" tab on the navigation bar - that has sub navigation that lists all the cities on a drop down menu. When this happens the URL string looks like http://www.domain.com/service/city The other choice would be to create individual TABS on the NAV bar, by doing this the URL string would look - http://www.domain.com/city . I could be wrong, but I am assuming the http://www.domain.com/city is better than http://www.domain.com/services/city for SEO purposes, ....if I am correct is there a way to make SUB Menu URLS appear as http://www.domain.com/city ? Any input as always would be appreciated best regards, Jimmy
Web Design | | jimmy02251 -
Website Redesign 301 Question
Hey Moz gang, I have a question that I believe I know how I'm going to handle, but just wanted some feedback from the Moz community on best practices. At my company, we're going through a site redesign. At the moment, our site is deeper than it should be with many one-off feature pages. For example, we have a Features page that then links to individual pages for each specific feature. One goal we have set for the redesign is a condensing of the pages in order to make the site more user-friendly, easy to manage and content rich. My question is this. We have a lot of these individual pages that I want to essentially kill and merge into one page. It is okay (best practice) to 301 all of those individual feature specific pages to the single Features page since that is now where all of that content lives?? I want to retain the link juice that those pages have gained over time, but I don't want to get penalized for too many 301's to a single page. Any advice or previous experience would be awesome 🙂 Thanks, Lance
Web Design | | RobinBryant10 -
Show root domain (that is 301 redirected) in SERP?
Hi, If I have the domain name www.businessname.com.au pointing (using 301 redirect) to a particular page on a business directory site (eg www.bizdirectory.com.au/businessname), is it possible to have the URL www.businessname.com.au displayed in the Google search results rather than the destination page of www.bizdirectory.com.au/businessname? Thanks in advance,
Web Design | | blackrails
Adam0 -
How does the toolbar caclulate text to code ratio?
I am seeing some very weird text to code ratios on a competitor site (over 100%) through the Analyze feature on the SEOmoz toolbar. I'm wondering how that's calculated, and what my competitors might be doing to raise that ratio so high artificially. I need to turn in a report on this soon, any help is greatly appreciated!! EHR
Web Design | | EHR0