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
-
Subdomain or Country Code Top Level Domain
Hello Friends, I am planning to develop my website for other languages. which one is best for SEO? (The main English website is well ranked in google) 1. de.example.com (subdomain may obtain rank faster as it is part of the main website?)
Web Design | | Bold
2. example.de (this is a completely new one; so not easy to get rank?) thank you
Barsbold0 -
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 -
Has anyone added Structured Data Markup Server Side?
I want to add some structured data to our companies website via microdata through schema.org. I have been asked to gather all of the requirements so that it can be done server side and automated when things change. I honestly don't know where to begin as there are many areas where it can be added. Has anyone done this server side before?
Web Design | | Sika220 -
How do I move a 200+ website properly with 301 redirect?
I tried to search for the answer but didnt find any direct answers. I need to move a 200+ site to a wordpress site. How am I suppose to 301 redirect all of them? Do I need to create the new pages first then have webmaster use ssh and 301 the entire list? Can anyone link me to a 1,2,3 step instructions for a huge website move? Im sure there are other issues that I need to know about.
Web Design | | bryonstout0 -
Websites with only one "html file" and page href # is good for SEO?
I bought one website from templatemonster that contains only one HTML and the pages are generated by links (PROGRAMACAO) My website: www.nextformaturas.com.br This is good in term of SEO? or it is better an website with deveral pages with diferent contents? What are the pros and cons? I really lost on this.
Web Design | | Naghirniac0 -
Crawl Diagnostics, 57 5XX (Server Error)'s
Hi guys, My name is Rob, and I work at Burst! Creative Group in Vancouver BC. We are having issues with the 5XX(server Error)'s. We have 57 of them, and can't figure out why! We have never had this problem before, but have recently added a blog to our website, and figure that this addition may have caused some problems. I'm hoping that I can get some helpful information from you MOZers to eliminate these crawl errors. You can take a look at our website at www.burstcreativegroup.com . Thank you in advance for all of your input! Rob
Web Design | | burst0 -
Coding a WordPress shopping cart
I have searched high and low for a light, simple to use Wordpress shopping cart plugin which can use custom templates and work with the transporter and payment gateway i'd like. Unfortunately i haven't found anything. I am currently looking for an example, maybe a tutorial somewhere but can't seem to find anything online, all i can find are advertisements for existing plugins. Can anyone help my any further? I know it's not an SEO related question but i'm out of ideas.
Web Design | | ldestrooper0 -
Dynamic pages and code within content
Hi all, I'm considering creating a dynamic table on my site that highlights rows / columns and cells depending on buttons that users can click. Each cell in the table links to a separate page that is created dynamically pulling information from a database. Now I'm aware of the google guidelines: "If you decide to use dynamic pages (i.e., the URL contains a "?" character), be aware that not every search engine spider crawls dynamic pages as well as static pages. It helps to keep the parameters short and the number of them few." So we wondered whether we could put the dynamic pages in our sitemap so that google could index them - the pages can be seen with javascript off which is how the pages are manipulated to make them dynamic. Could anyone give us a overview of the dangers here? I also wondered if you still need to separate content from code on a page? My developer still seems very keen to use inline CSS and javascript! Thanks a bundle.
Web Design | | tgraham0