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
-
Duplicate H1 Question & Landing Page help
Hi We have 2 H1's on this page http://www.key.co.uk/en/key/heavy-duty-shelving Our webmaster has put one as display:none - but isn't this just going to look like we're keyword spamming & trying to hide it? OK now I;m looking I am seeing more wrong with this page... The width buttons at the top as h2's...& they link to facet pages? Won't this just waste crawl budget? and every product title/user guide title etc are all H2's.... I just need to put a plan together to give to our dev team on what should be updated Any tips would be great. Becky
Intermediate & Advanced SEO | | BeckyKey0 -
2 menus Responsive website Seo question
Hi there Thanks for reading my post. İ am fairly new to SEO and dont know much coding. İ purchased an opencart theme and am working with a developer to modify it to make it more user friendly. The website is responsive and İ modified the menu for the desktop but now it doesnt have categories but just products. So it doesnt have URL for categories but just filter. So the developer recommended to add the mobile menu which has categories, and subcategories back to the desktop menu. İm not sure if this is a kosher approach to seo. Here is the link: As you can see there is a menu in the top menu and menu on the Main Menu. THoughts? will this be problem for duplicate content? The Main menu keywords are crucial and is what the website is revolving around. New website
Intermediate & Advanced SEO | | socratic-goat7770 -
Scraping / Duplicate Content Question
Hi All, I understanding the way to protect content such as a feature rich article is to create authorship by linking to your Google+ account. My Question
Intermediate & Advanced SEO | | Mark_Ch
You have created a webpage that is informative but not worthy to be an article, hence no need create authorship in Google+
If a competitor comes along and steals this content word for word, something similar, creates their own Google+ page, can you be penalised? Is there any way to protect yourself without authorship and Google+? Regards Mark0 -
Help with htaccess
I just setup a WP install in a subfolder: domain.com/development/ However, there is an existing htaccess file in the root which contains the following: RewriteRule ^([A-Za-z_0-9-]+)$ /index.php?page=$1 [QSA]
Intermediate & Advanced SEO | | SCW
RewriteRule ^([A-Za-z_0-9-]+)/$ /index.php?page=$1 [QSA]
RewriteRule ^([A-Za-z_0-9-]+)/([a-z]+)$ /index.php?page=$1&comp=$2 [QSA]
RewriteRule ^([A-Za-z_0-9-]+)/([a-z]+)/$ /index.php?page=$1&comp=$2 [QSA] I need to leave the rules as-is due to the nature of CMS (not WP) under the root domain. Is it possible to include an exception or condition which allows URL requests containing /development/ to resolve to that folder? I tried to add: RewriteRule ^development/([A-Za-z_0-9-]+)$ /development/index.php?page=$1 [QSA] but this seems to send it in a loop back to the root. Thanks!!!0 -
301 Redirect htaccess
Hi Guys, I have a website that has plenty of links with parameters. For example:
Intermediate & Advanced SEO | | UrbanMark
http://www.domainname.co.uk/index.php?app=ecom&ns=catshow&ref=Brandname-Golf-Shorts&sid=201v04gxs2hlozv161tfo43qk98583el I want to place a wildcard redirect on the .htaccess but don't know what exactly code for this. Ideally I want the URLs above to be: http://www.domainname.co.uk/Category/Brandname-Golf-Shorts Any help pls. Thanks,
Brucz0 -
Question For Anyone
Hi All, Would you be able to answer one small question If you go to Australian Google - www.google.com.au and search for "loans" on positions number # 38 you will see the following site paydayloansyouknow.com.au . It has only 3 pages , 0 links, PA 1,and DA 1 How it's possible to archive such results? This is the print screen in case you dont see what i am asking about
Intermediate & Advanced SEO | | Webdeal
( http://www.freeimagehosting.net/oa75d Will appreciate any answer?0 -
Another E-commerce Canonical Question
Hi guys, Quick question: one of our clients has an e-commerce site with a very poor canonical tag setup and thousands of pages of duplicate content. Let's use this as an example: BRAND > Category > Type > Color
Intermediate & Advanced SEO | | elcrazyhorse
Four separate pages/URLs. The BRAND page lists all products.
The Category page lists all BRAND products for that category.
The Type page lists all BRAND products of a specific type in that category.
The Color page lists all BRAND products of a specific type in that category of a specific color. Anyway, these generate four separate URLs: /BRAND
/BRAND/Category
/BRAND/Category-Type
/BRAND/Category-Type-Color Avoiding duplicate content and product listings, I would appreciate your proposed canonicalization strategy/feedback.0 -
Spammy Link Profile Questions. What do you think?
I'm trying to dilute the link profile for a website. But have a couple of questions on the best way to achieve this. Current link profile, www.mysitename.com Keyword 1 Keyword 2 Keyword 3 Keyword 4 Keyword 5 Keyword 6 Keyword 7 Keyword 8 Keyword 9 Keyword 10 Keyword 12 Keyword 13 Keyword 14 Keyword 14 Keyword 15 mysitename.com Desired link profile, www.mysitename.com mysitename.com www.mysitename.com http://www. mysitename.com/ My Site Name http://mysitename.com Click Here my site name More Info mysitename.com/ www.mysitename.com/ Keyword 1 Keyword 2 Keyword 3 Keyword 4 Keyword 4 Keyword 5 Questions 1. Do you think Google looks at this on a domain level? Or do you think this needs to be done with every page on the site? 2. What would be a good way to build links fast to the pages, need to build lots of links to be able to dilute the profile. I was considering Dripable, or a similar service, but decided i really don't want to create more spam.What would you do? 3. What would you say the % threshold for anchor text is, i have read on different sources that at least 40% - 60% of links should be branded, url, or generic anchor links. Do you think this is accurate?
Intermediate & Advanced SEO | | 858-SEO0