Infinite Redirect Loop without trailing slash, please help
-
I've been searching for an answer all day, I can't seem to figure this out.
When I Fetch my blog as Google(http://www.mysite.com/blog) WITHOUT a trailing slash at the end, I get this error:
The page seems to redirect to itself. This may result in an infinite redirect loop
**HTTP/1.1 301 Moved Permanently**
When I Fetch my blog as Google WITH the trailing slash at the end(http://www.mysite.com/blog/), it is fine without errors.
When I pull it up in a browser comes up fine both with and without the trailing slash.
My .htaccess file in the root directory contains this:
RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index.htm\ HTTP/
RewriteRule ^index.htm$ http://www.mysite.com/ [R=301,L]
RewriteCond %{HTTP_HOST} ^mysite.com$
RewriteRule ^(.*)$ http://www.mysite.com/$1 [R=301,L]My .htaccess file in the blog directory contains this:
BEGIN WordPress
<ifmodule mod_rewrite.c="">RewriteEngine On
RewriteBase /blog/
RewriteCond %{REQUEST_URI} ^./index.php/. [NC]
RewriteRule ^index.php/(.*)$ http://www.mysite.com/blog/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]</ifmodule>END WordPress
Do I have something incorrectly coded in these .htaccess files that could be causing this? Or is there something else I should look at? Thank you for any help!!
-
I combined the htaccess files (putting the blog rewrite rule to the bottom of the file) now having just one htacess in the root directory and unfortunately it did not work. When I tried it, all the links on the blog would not work, they were all "page not found" so I reverted it back to what I originally had... Here is what the combined htaccess file looked like:
RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index.htm\ HTTP/
RewriteRule ^index.htm$ http://www.example.com/ [R=301,L]
RewriteCond %{HTTP_HOST} ^example.com$
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]<ifmodule mod_rewrite.c="">RewriteEngine On
RewriteBase /blog/
RewriteCond %{THE_REQUEST} ^./index.php/. [NC]
RewriteRule ^index.php/(.*)$ http://www.example.com/blog/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]</ifmodule>Thanks again for any insight!
-
Hey Debora,
Any luck?
Keith
-
Hello Debora,
Make sure you keep copies of your .htaccess files before you make changes and, if you can, use a test site to test your changes first before you make changes on your live website.
I'm not sure how your website is set up so I don't know if combining the two files will accomplish what you are looking for.
Whatever you do, make sure you have backups.
-
Yes as I said above
-
Thanks for your response Keith, I'll give it a try and let you know!
-
Thanks George. Please forgive me, I am a newbie at this! I took a look at the link you provided, and I don't fully understand what they are explaining. What I did understand is that having 2 htaccess files in different directories caused a problem with their code. Do you think combining the two files into one on the root directory will make a difference for me?
-
Sorry, I completely misread this question (I missed the part where you said you had to .htaccess files!).
Yes put one .htaccess file in the root dir, add the blog rewrite rule to the bottom of the file.
Let me know how it goes.
Keith
-
Thanks Keith. I tried it and it is still looping. Do you think it has something to do with having 2 different .htaccess files? Should I combine them into just one in the root directory?
-
Yuk mod_rewrite...
Try:
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index.php\ HTTP/
RewriteRule ^index.php$ http://www.example.com/blog/ [R=301,L]You may wish to add $1 on the end
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index.php\ HTTP/
RewriteRule ^index.php$ http://www.example.com/blog/$1 [R=301,L]Let me know if that stops it looping...
Keith
-
Try here. Maybe that will help.
Edit: Pretty sure it's your root directory .htaccess file that is causing the looping. I'd start with that.
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 Critical to Address Redirect Chains?
We have about 100 redirect chains and were not sure of the impact they are having on our SEO. One SEO expert wants to charge around $800 to clean these up for us. Any thoughts on how serious of an issue this is and how important it is to address?
Intermediate & Advanced SEO | | roundtable10 -
301 Redirecting from domain to subdomain
We're taking on a redesign of our corporate site on our main domain. We also have a number of well established, product based subdomains. There are a number of content pages that currently live on the corporate site that rank well, and bring in a great deal of traffic, though we are considering placing 301 redirects in place to point that traffic to the appropriate pages on the subdomains. If redirected correctly, can we expect the SEO value of the content pages currently living on the corporate site to transfer to the subdomains, or will we be negatively impacting our SEO by transferring this content from one domain to multiple subdomains?
Intermediate & Advanced SEO | | Chris81980 -
Help! Website Page Structure.
Hi there, I have a cupcake website; www.cupcakesdelivered.com.au To date, we have sold only regular cupcakes. Moving forward, we are about to start selling lots of different sorts of cupcakes and want to categorise them - i.e.; sport cupcakes, corporate cupcakes, movie-themed cupcakes etc. I am looking for a recommendation on how best to structure this in terms of pages / domains / subdomains etc, so as to best support SEO. Your help would be greatly appreciated!! Thank you, Laura.
Intermediate & Advanced SEO | | cupcakesdelivered0 -
Site Redesign Inconsistent Trailing Slash Issue
I'm looking at a site that has implemented trailing slashes inconsistently across multiple pages. For instance:
Intermediate & Advanced SEO | | GrouchyKids
http://www.examplesite.co.uk/ (WITH)
http://www.examplesite.co.uk/product-range (WITHOUT)
http://www.examplesite.co.uk/product (WITHOUT)
http://www.examplesite.co.uk/blog/ (WITH)
http://www.examplesite.co.uk/blog/blog-article/ (WITH) The blog was created later in Wordpress which is one of the reasons why this issue exists. Looking at the inbound links unsurprisingly the lions share go to the home page but lots of other pages have links as well, particularly the product pages, no to many to the blog pages. This pattern is similar in terms of which pages rank, the home page ranks well for a variety of phrases, the product pages also do quite well. I know that ideally the URL's should be identical to the existing site, or if you have to you should 301 redirect old to new. The client wants to switch the whole site over to Wordpress which will be default implement a consistent URL structure across the board, thereby changing at least some of the URL's no matter what I do. I remember a Matt Cutts video that stated that even a 301 redirect will loose a clicks worth of link juice see: https://www.youtube.com/watch?v=Filv4pP-1nw The existing site has a poor UX compared to the new proposed design so this should help us. Has anyone got any experience with a similar issue or any advice about how best to proceed?0 -
Redirect help
I work for a company that has a domain that is something like www.neat-stuff.com but most people just use www.neatstuff.com without the dash. The redirect for the homepage works fine. We recently launched a new site and if you use www.neat-stuff.com/category it redirects from the old site to the new site just fine. However if you use www.neatstuff.com/category it does not properly redirect to www.neat-stuff.com/category. How do I fix that?
Intermediate & Advanced SEO | | EcommerceSite0 -
301 redirect or rel=canonical
On my site, which I created with Joomla, there seems to be a lot of duplicated pages. I was wondering which would be better, 301 redirect or rel=canonical. On SeoMoz Pro "help" they suggest only the rel=canonical and dont mention 301 redirect. However, ive read many other say that 301 redirect should be the number one option. Also, does 301 redirect help solve the crawling errors, in other words, does it get rid of the errors of "duplicate page content?" Ive read that re-=canonical does not right? Thanks!
Intermediate & Advanced SEO | | waltergah0 -
301 redirect
I have 2 websites, lets call them Website A and Website B. Website A is a commercial website, website B is a 7 years old blog. Website B has many natural, high quality BL, including some from Nytimes, etc. I want to integrate the blog (B) into the commercial website (A). The idea behind this thought is to compress the two websites, it is easier to have everything in one place. I will do this with 301 redirect via Webmaster tools, htaccess etc. The uRL structure will remain the same: eg: websiteB/post-title/ -> websiteA/post title What will happen with my quality BLs? Is there any chance to be penalized by Google? What will happen with the PR of the 2 sites? Thanks.
Intermediate & Advanced SEO | | jasmin281 -
Setting up of 301 redirects
Good morning all, As part of the analysis of our website, we have realised that we are diluting our keyword strength in a particular area by having multiple zones all targeting the same keyword. We have decided to combine these zones into one, and set up 301 redirects so that the remaining zone gets the benefit of the other zones' link juice. When setting up a 301 redirect from zone "X" to zone "Y" say, do I need to keep all of the content in zone X, or should I remove all content before the redirect is set up? Does zone Y still get the benefit of zone X's link juice if the content is removed? Many thanks Guy
Intermediate & Advanced SEO | | Horizon0