Redirect question
-
I would like to redirect http://example.com/index.html to http://www.example.com/
Is the code below correct ?
RewriteEngine on
RewriteCond %{HTTP_HOST}^example.comRewriteRule (.*)
http://www.example.com/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index.html\ HTTP/
RewriteRule ^index.html$ http://www.example.com/ [R=301,L]
-
I would go with the code the way Rasmus has laid it out for you. I will check out the tool and let youknow.
-
Many Many Thanks Robert for the useful link.
I tried the tool but it didn't generated the code as stated above. Have i missed something ?
-
Thanks Rasmus Olesan.
-
Atul, I think the way Rasmus has it here is correct. The other day I came across a tool for 301's that will write for you. FULL Disclosure is I have not used it yet. If you want to check it out, the site is
http://seo-website-designer.com/HtAccess-301-Redirect-Generator
Might be worth a try.
-
The first portion of your code seems correct, although the line breaks are a bit off in the post? We have a similar approach for forwarding non-www to www-pages.
RewriteCond %{HTTP_HOST} ^domain.com [NC] RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]
I've google a bit and found the following code:
All in all, I would say your .htaccess code should be:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain.com [NC]
RewriteRule ^(.)$ http://www.domain.com/$1 [L,R=301]
RewriteCond %{THE_REQUEST} ^./index.html
RewriteRule ^(.*)index.html$ http://www.domain.com/$1 [R=301,L]Best way to get an answer? Try uploading the .htaccess code and see if it works - if not, take it down again and correct the code. However the above should work I should think.
-Rasmus
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
-
Recently migrated to https version of volusion site. 301 redirect link chain question
I recently migrated to a https version of a volusion site. They have some type of internal 301 redirect method to accommodate for the entire site. I have also used the 301 redirect manager to redirect categories and pages which I have changed. The question is if I have changed a page internally in the redirect manager from say source. /bluewidget to say. target. /superbluewidget is it wiser or even possible to do it this way to reduce the redirect chain from 3 to 2 steps source. /bluewidget to. target https://www.example/superbluewidget can a relative link be targeted to a full url to reduce steps in a 301 redirect link chain. Thanks
Technical SEO | | mrkingsley0 -
301 Redirect Best Practices
Hi SEOs, Question about ranking/redirects. If I have a particular page that is already ranking for a couple KWs in top SERPs, but know there are higher volume KWs I can optimize for should I just leave it as is or change the URL key and redirect for the time being until Google re-indexes. Example:
Technical SEO | | IceIcebaby
current URL: www.example.com/action/best-movies
new URL: www.example.com/action/best-action-movies
(the current would be ranking for "best action moves" whereas the new would include the actual "best action movies" KW) Let me know if I can clarify, thank you!0 -
Rebranding / Redirecting
Hi I have a client who wants to re-brand their shopify clothing store under new domain name. Whilst still a clothing store its going to have different department structure and product pages and will hence be a different store/site. Is there anyway to pass any of the history/authority of existing site to the new one such as 301 redirecting the top level pages of existing site to nearest equivalent pages of new site etc or best to just redirect the old site domain to the new ? Cheers Dan
Technical SEO | | Dan-Lawrence0 -
Keyword density question.
For instance, if the keyword I'm targeting on a specific page is "New Orleans", the Keyword is everywhere it's supposed to be, title, meta, content, internal links, etc, .... So when I check my most relative key words with different tools, it always breaks the word up like: new - 12 times 2.3% orleans - 12 times 2.3% Should I try to fix this? or is this normal? and does google view this as 1 keyword when evaluating my site?
Technical SEO | | Nola5040 -
Redirecting 404
Hi. I'm working on a wordpress site, which got some old deleted pages indexed and now shows a 404 (also in the results) As these old pages earlier got content and probably also some links pointing towards it, what would then be best practice to do? Should i make an 301 redirect? Make the 404 noindex?
Technical SEO | | Mickelp0 -
Does 301 redirect cause penalty
Good Morning, I am considering doing a 301 (permanent) re-direct of roughly 100 domains, split between my 3 main e-commerce sites. Would taking an action like this put any of the 100 domains or any of the 3 recipient domains at risk of violating G's guidelines? Thanks...
Technical SEO | | Prime851 -
Redirecting Parked Domain
I just recently switched hosting. We have 3 domains and 1 being the main domain. Right now they are set up as parked domains. Can I redirect the parked domains under my main websites .htaccess file ? I am just worried that good we will get hit for duplicate content, even though technically the content is only on our main domain. right now if I type in my parked domains in Google, they appear in search. The site is all hand coded and not using a CMS.
Technical SEO | | hfranz0 -
301 Redirect & Cloaking
HEllo~~~~ People. I have a question regarding on cloaking. I will be really greatful if you can help me with question. I have a site www.example.com and it is targeting for multi countries. So I use sub directories for targeting multi countries. e.g. www.example.com/us/ www.example.com/de/ www.example.com/hk/ ....... so on and on. Therefore, when people type www.example.com, I use IP delivery to send users to each coutries. Here is my question. I use 301 redirect for IP delivery, which means when user enter www.example.com, my site read user's IP and send them to right country site by 301 redirect. In this case, is there any possibility that Google considers it as cloaking? Please people.... share me some ideas and thoughs.
Technical SEO | | Artience0