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
-
Content From API - Remove or to Redirect ?
Hi Guys,
Intermediate & Advanced SEO | | PaddyM556
I am working on a site at the moment,
Previous developer used a API to pull in HealthCare content (HSE) .
So the API basically generates landing pages within the site, and generates the content.
To date it has over 2k in pages being generated.
Some actually rank organically and some don't. New site being launch: So a new site is being launched & the "health advice" where this content used to live be not included in the new site. So this content will not have a place to be displayed. My Query: Would you allow the old content die off in the migration process & just become 404's
Or
Would you 301 redirect the all or only ranking pages to the homepage ? Other considerations, site will be moved to https:// so site will be submitted to search console & re-indexed by Google. Would love to hear if anyone had similar situation or suggestions.
Best Regards
Pat0 -
HTTPS 301 Redirect Question
Hi, I've just migrated our previous site (siteA) to our new url (siteB) and I've setup 301 redirects from the old url (siteA) to the new (siteB). However, the old url operated on https and users who try to go to the old url with https (https://siteA.com) receive a message that the server cannot be reached, while the users who go to http://siteA.com are redirected to siteB. Is there a way to 301 redirect https traffic? Also, from an SEO perspective if the site and all the references on Google search are https://siteA.com does a 301 redirect of http pass the domain authority, etc. or is https required? Thanks.
Intermediate & Advanced SEO | | opstart0 -
Please help with serp placment question?
We own discount banner printing and we are trying to rank 1 for pvc banners or vinyl banners and cannot understand for example how the below is correct, we did suffer a link penalty years ago but we fixed this and the domain has some good links (more and better quality than the sites above us) and cannot understand how we rank below most of the sites above us? If we type on for example pvc banners we get http://www.bannershop.co.uk/cats/pvc_banners.htm https://www.hfe-signs.co.uk/banners.php http://bannerprintingandroid.co.uk/pvc-banners/ http://www.discountbannerprinting.co.uk/banners/vinyl-pvc-banners.html And if we type in vinyl banners we get http://www.vistaprint.co.uk/banners.aspx http://www.bigvaluebanners.co.uk/ http://vinylbannersprinting.co.uk/ http://www.discountdisplays.co.uk/html/vinyl_banners.html https://www.buildasign.co.uk/banners http://www.monkey-print.com/outdoor banners/budget-outdoor-banners http://www.discountbannerprinting.co.uk/banners/vinyl-pvc-banners.html
Intermediate & Advanced SEO | | BobAnderson0 -
Is there anything wrong with this 301 redirect?
I'll keep this one short and sweet 🙂 Many moons ago we used to have several different methods of sorting our products and this change in sort order was achieved by having ?dispmode=list or ?dispmode=grid after the product URL. Best part of a year ago we decided to scrap this feature and 301'd all the ?dispmode URL's back to the base URL. The funny thing is that Google don't seem to have dropped a single one of the old URL's from their index and a search for site:www.refreshcartridges.co.uk dispmode returns almost 8,000 results. This isn't a massive problem but I'd have expected in the past year they'd have picked up on a couple of the 301's and would have started removing the old results. I'd hate to think we were getting any kind of penalisation for duplicate pages. I know the answer to this question is going to be 'just be patient, the old results will disappear' but just to ensure we're not missing anything stupid. I'd really appreciate it if someone could check out www.refreshcartridges.co.uk/brother-c-223.html?dispmode=list to confirm there's nothing more we could be doing to get these old results removed from the index. Many thanks
Intermediate & Advanced SEO | | ChrisHolgate0 -
Can someone please help me understand my sites recent loss of rankings?
My site has been top 3 for 'speed dating' on Google.co.uk since about 2003 and it went to below top 50 for a lot of it's main keywords shortly after 27 Oct 2012. I did a re-submission request and was told there was 'no manual spam action'. I have a Page Authority of 53, a regular blog http://bit.ly/oKyi88, a KLOUT of 40, user reviews and quality content. I did discover that another URL I using was set to a 302 instead of a 301 for some reason. I don't necessarily think this was an issue as Google should know which is the trusted URL and therefore which content to list. I removed this redirect completely about 3 weeks ago, but I've seen no improvement. I'm looking at improving various things, but I'm still not sure why I've been hit and wonder if I'm missing something obvious? Any suggestions greatly appreciated.
Intermediate & Advanced SEO | | benners0 -
SEO Feedback Please
Hi, I was hoping to get some feedback on this site's SEO: http://www.chantre.com/ I also have different URLs which can be accessed from the left side of the site under "Quick Search Links" that go to the different offices within this company. Thoughts on how to improve would be great. Thanks in advance.
Intermediate & Advanced SEO | | gXe0 -
redirect 404 pages to homepage
Hello, I'm puting a new website on a existing domain. In order to not loose the links that point to the varios old url I would like to redirect them to homepage. The old website was a mess as there was no seo and the pages didn't target any keywords. Thats why I would like to redirect all links to home. What do you think is the best way to do this ? I tried to ad this in the .htaccess but it's not working; ErrorDocument 404 /index.php Con you tell me how it exacly look? Now the hole file is like this: @package Joomla @copyright Copyright (C) 2005 - 2012 Open Source Matters. All rights reserved. @license GNU General Public License version 2 or later; see LICENSE.txt READ THIS COMPLETELY IF YOU CHOOSE TO USE THIS FILE! The line just below this section: 'Options +FollowSymLinks' may cause problems with some server configurations. It is required for use of mod_rewrite, but may already be set by your server administrator in a way that dissallows changing it in your .htaccess file. If using it causes your server to error out, comment it out (add # to beginning of line), reload your site in your browser and test your sef url's. If they work, it has been set by your server administrator and you do not need it set here. Can be commented out if causes errors, see notes above. Options +FollowSymLinks Mod_rewrite in use. RewriteEngine On Begin - Rewrite rules to block out some common exploits. If you experience problems on your site block out the operations listed below This attempts to block the most common type of exploit attempts to Joomla! Block out any script trying to base64_encode data within the URL. RewriteCond %{QUERY_STRING} base64_encode[^(]([^)]) [OR] Block out any script that includes a
Intermediate & Advanced SEO | | igrizo0 -
Newbie to SEO and SEOMOZ help
Hey everyone i just came across SEOMOZ today, i have been building websites for 3 years now but SEO is something which has always been a scary topic to consider trying to master. I have made a decision to do this in 2012 and i have been looking for a software package which can stear me and teach me. I have been reading the site help today and i feel totally swamped! i have created my campaign but a lot of the results dont make much sense to me and i am unsure of how to fix the errors they found. For instance the crawl diagnostics shows i have 5 4xx client errors. They show me a link to the page where the error is http://www.mydomain.com/category/latest-news/function.require but when i go to see what this is i just find an error 404 not found page.How do i go about removing this error if i have no idea where the problem is? I have started reading SEO User guide and beginers guide and i know it is going to take me a long time to get use to this all, but i am struggling to find the starting point and hope someone can possible help me find the first few steps. Thanks
Intermediate & Advanced SEO | | buntrosgali0