Quick htaccess question
-
Hi! I'm trying to do a 301 from www.stevesims.com/index.htm to www.stevesims.com.
I know I need to use the request command to avoid an infinite loop, but I can't quite figure out the correct code. Here's the first part of the htaccess file.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^stevesims.com
RewriteRule (.*) http://www.stevesims.com/$1 [R=301,L]RewriteCond %{HTTP_REFERER} !^http://stevesims.com/.$ [NC]
RewriteCond %{HTTP_REFERER} !^http://stevesims.com$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.stevesims.com/.$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.stevesims.com$ [NC]
RewriteRule .*.(jpg|jpeg|gif|png|bmp)$ - [F,NC]Any suggestions would be much appreciated.
-
Ideally, you should avoid 301 redirect from index.php, as it will cause to go in infinite loop. I too have used 301 redirect earlier, but later applied a better way is Rel=canonical tag
Still, if you look for 301 redirect - below is the code which will help redirecting :-
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.index.html\ HTTP/
RewriteRule ^(.)index.html$ /$1 [R=301,L]May also see this url for all sort of redirection from html, php, non www page to www page http://www.gabblet.com/post/2011/09/27/301-redirect-for-index-non-www-to-www-using-htaccess.aspx
Let know how it goes
-
This is my code : it redirect all
mysite.com to www.mysite.com and mysite.com/index.php to mysite.com (need to rename htaccess.txt to .htaccess)
<ifmodule mod_rewrite.c=""># Redirect non-www to www
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^yoursite.com
RewriteRule (.*) http://www.yoursite.com/$1 [R=301,L]</ifmodule>RewriteBase /
RewriteCond %{HTTP_HOST} !^www.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^.]+)$ $1.php [NC,L]RewriteCond %{THE_REQUEST} ^[A-Z]+\ /([^/]+/)[^.#?\ ]+.php([#?][^\ ])?\ HTTP/
RewriteRule ^(([^/]+/)*[^.]+).php http://www.yoursite.com/$1 [R=301,L]
RewriteRule ^index.php$ - [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
-
How to be included in related questions (People also ask) in Google SERP?
Just wondered if anyone knows how to be included in SERP if it comes to related questions (People also ask). Do you have to fill some requirements or is it featured snippets kind of thing.
Intermediate & Advanced SEO | | Optimal_Strategies1 -
Site Migration Question - Do I Need to Preserve Links in Main Menu to Preserve Traffic or Can I Simply Link to on Each Page?
Hi There We are currently redesigning the following site https://tinyurl.com/y37ndjpn The local pages links in the main menu do provide organic search traffic. In order to preserve this traffic, would be wise to preserve these links in the main menu? Or could we have a secondary menu list (perhaps in the header or footer), featured on every page, which links to these pages? Many Thanks In Advance for Responses
Intermediate & Advanced SEO | | ruislip180 -
Disavow File and SSL Conversion Question
Moz Community, So we have a website that we are moving to SSL. It has been 4 years since we submitted our disavow file to google via GWT. We decided to go through our backlinks and realized that many domains we are disavowing currently (under Since we are moving to SSL I understand Google looks at this as a new site. Therefore, we decided to go through our backlinks and realized that many domains we are disavowing currently are no longer active (after 4 years this is expected). Therefore, is it ok to create a new disavow file with the new profile on GW (ssl version of our site)? Also, is it ok the new GW disavow file doesn't include urls we previously disavowed with the non https version? Some links from the old disavow we found were disavowed but they shouldn't have been. Moreover, we found new links we wanted to disavow as well. Thanks QL
Intermediate & Advanced SEO | | QuickLearner0 -
Technical SEO Question: Why is our new platform showing a small decline in traffic?
Hi there! We are in the process of transitioning to a faster platform, and we recently moved a subset of URLs over. The subset that moved over saw a drop. We didn't change the URL pattern, or the content. The only thing that is different is the new platform. Here's a link to one of the URLs that is currently served from the new platform: http://bit.ly/1YjXD7H And, here is an example of a URL currently served from the older platform: http://bit.ly/1Jtx7Di Any ideas why the newer platform is seeing a decline in organic traffic?
Intermediate & Advanced SEO | | nicole.healthline0 -
Video Sitemap Creation Question
I have created a sitemap file as per Google Web Master Tools instructions. I have it saved as a .txt file. Am I right in thinking that this needs to be uploaded as a .xml file? If so, how do I convert this to a XML? I have tried but it seems to corrupt - there must be a simple way to do this?!
Intermediate & Advanced SEO | | DHS_SH0 -
To "Rel canon" or not to "Rel canon" that is the question
Looking for some input on a SEO situation that I'm struggling with. I guess you could say it's a usability vs Google situation. The situation is as follows: On a specific shop (lets say it's selling t-shirts). The products are sorted as follows each t-shit have a master and x number of variants (a color). we have a product listing in this listing all the different colors (variants) are shown. When you click one of the t-shirts (eg: blue) you get redirected to the product master, where some code on the page tells the master that it should change the color selectors to the blue color. This information the page gets from a query string in the URL. Now I could let Google index each URL for each color, and sort it out that way. except for the fact that the text doesn't change at all. Only thing that changes is the product image and that is changed with ajax in such a way that Google, most likely, won't notice that fact. ergo producing "duplicate content" problems. Ok! So I could sort this problem with a "rel canon" but then we are in a situation where the only thing that tells Google that we are talking about a blue t-shirt is the link to the master from the product listing. We end up in a situation where the master is the only one getting indexed, not a problem except for when people come from google directly to the product, I have no way of telling what color the costumer is looking for and hence won't know what image to serve her. Now I could tell my client that they have to write a unique text for each varient but with 100 of thousands of variant combinations this is not realistic ir a real good solution. I kinda need a new idea, any input idea or brain wave would be very welcome. 🙂
Intermediate & Advanced SEO | | ReneReinholdt0 -
Retargeting questions
The question is in reference to SEOmoz post - http://www.seomoz.org/blog/retargeting-basics-what-it-is-how-to-use-it 1. What is the size of a retargeting pixel and who places it on the site ? Is it the retargeting company ? Can we place it ourselves ? Does a code have to be added to the site ? 2. In the post mentioned above, the author talks about "burn pixel" "If a person in your audience converts then a "burn pixel" will fire" What do you mean by burn pixel ? How do we come to know that a burn pixel has fired ?
Intermediate & Advanced SEO | | seoug_20050 -
Quick ranking boost
Hi, What is hte quickest way to get up the rankings for a particular not hugley competitive keyword ? Thanks,
Intermediate & Advanced SEO | | Prongo0