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
-
301 redirects delay in picking up
Hi I have been involved in the redesign/development of a website which has up until now had a lot of international traffic. On day of migration I uploaded all the 301 redirects to the website (wordpress) using Simple 301 redirect plugin. I tested a number of them and they appeared to be working. I also submitted the new sitemaps to Search Console. Since migration international traffic - particularly from countries such as india, Phillipines, Sri Lanka etc have significantly dropped off whereas the local traffic and some of the international traffic such as USA has remained fairly consistent. Looking at Analytics and entrances recently it appears as though search results are/were showing a number of pages with 404's (one in particular which received significant traffic and for which I had created a 301 redirection) - I have checked this page using the old url and it re-directs correctly for me and today asked a colleague in India to also check - he is getting the redirection fine. Does Google.in take a significantly longer time to pick these up in search results? Or am I missing something?
Technical SEO | | musthavemarketing0 -
301 Redirect domain with penalty
Wondering if I could get a few views on this please... I have added an affiliate store to a domain I own, however I forgot to noindex the product pages which were duplicate content of the merchants. Despite a good deal of backlink building the site will not do much in the engines at all, doesn't even come up on the first few pages for it's own name! This suggests to me that I have a duplicate content penalty. Try as I may I cannot get it removed so am thinking of cloning the domain to a new domain, however, I do not want to lose the links I collected so I am planning on 301ing them. While I will not get all the link power moved over, I should at least get credit for some of them which will kick start the new domain. Can anyone forsee any potential issues with doing this? Is there a danger of 301ing a site with a penalty that the penalty would be carried over? I know there is no penalty on the links, no WMT warnings etc, it is the content causing the issue. Thanks, Carl
Technical SEO | | Grumpy_Carl0 -
Drupal Question
So on our site we have a plugin for our fan gallery. The issue is that I am getting a lot of duplication errors and it's saying the URL is too long and all the errors are coming from the Fan Gallery, which has over 8,000 errors. It seems to be pulling a long form query URL that has over 100 characters. You can't physically see it on the site, but the crawlers can. Anyway I'm trying to figure out a fix for this. One method would be to just stop those pages from being crawled, but I would hate to do that as the fan gallery for us would be a great source of links and content. So I'm wondering if anyone else has had an issue with these types of plugins before where the user can upload a photo or do a video embed and then it submits to the site. If you have a better method please let me know. I usually work on E-comm platforms so my experience with drupal is limited.
Technical SEO | | KateGMaker0 -
Duplicate titles Question
Hi eveyone, I have around 1000 duplicate titles and meta description. The poblem was that I had pages in my home page and different pages had the same title. For example, index.php/site/articles/should_you_eat_protein_every_2-3_hours_for_muscle_growth/ /index.php/site/articles/should_you_eat_protein_every_2-3_hours_for_muscle_growth/N12//index.php/site/articles/should_you_eat_protein_every_2-3_hours_for_muscle_growth/N1444//index.php/site/articles/should_you_eat_protein_every_2-3_hours_for_muscle_growth/N1448//index.php/site/articles/should_you_eat_protein_every_2-3_hours_for_muscle_growth/N1448/P6//index.php/site/articles/should_you_eat_protein_every_2-3_hours_for_muscle_growth/N1452/I have 172 of the same page!So I took off all the pagination on my home page and just added 'click fo more'. When they click more, it takes them to the category.So my question is will google slowly start deleting or non-indexing these duplicate titles or pages as I have removed it from my website? (Just so that you know I added a canonical link and figuring out how to add page numbers to met titles and meta description tags for categories with pages)
Technical SEO | | anoopbal0 -
Domain Crawl Question
We have our domain hosted by two providers - web.com for the root and godaddy for the subdomain. Why SEOMOZ is not picking up the total pages of the entire domain?
Technical SEO | | AppleCapitalGroup0 -
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 -
Is this a safe 301 redirect?
We are moving our site from one platform to another. Currently on our site we have two homepages. "www.homepage.com" and "www.homepage.com/Index" Both pages have some high quality links pointing in on them. The problem: We are going to be doing a 301 redirect from "www.homepage.com/Index" page to "www.homepage.com" as we are moving platforms at this time we weren't going to create a "www.homepage.com/Index" page all. This leaves this page as an empty URL. With this webpage disappearing all together will we lose traction as we are redirecting an empty URL? Or is it better to recreate this "www.homepage.com/Index" on our new platform redirect it and wait for google to deIndex this page for us? As well is there a tutorial for how to implement 301 redirects or is this something worth looking for a developer and pay someone to do?
Technical SEO | | HCGDiet0