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.
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
-
Ugly Redirect Chain
Hey everyone, Hoping to get your take on this: We have some very high demand products, they usually sell out in minutes (lucky us, eh?!) We are implementing a queue function on a product page - basically if too many people try to check out at the same time, we dump them in a queue The queue could kick in before or after search engines have indexed the product page The product page has markup and on-page content relating to the product. The queue page exists on an external (yes, external) site The queue page will not have any of the product info, markup, or optimised page title Product page will 302 to queue page and starts a series of 302 redirects! Here's the sequence when queue is active: CANONICAL product page (with markup, on-page product info, optimised page title, etc.)
Intermediate & Advanced SEO | | TSEOTEAM
>> 302 >> queue page on external domain (ZERO markup, product info or page title)
>>302>> same queue page, but throwing a hashed queue ID into the URL (basically giving you your place in the queue)
HELD IN QUEUE FOR A FEW MINUTES
**>> 302> ** NON-CANONICAL product page (with markup, on-page product info, optimised page title, etc.) I can foresee two scenarios search engine has indexed product page prior to queue kicking in. Then queue kicks in 302ing search engine to queue page. because it's a 302 the crappy queue page content is indexed back to the originating product page. This causes search engines to drop the product page cos all the product-specific markup/content has been overwritten with crappy queue page content search engines don't manage to index product page before queue kicks in. They crawl product page URL, get 302 to queue page, index crappy queue page content and think the product page is crappy, so don't traffic it. They will recrawl the product page once the queue's turned off, only to discover the product has sold out - boo. I very much doubt the search engines will 'wait for a few minutes' so may never end up reaching the product page again. I'm trying to get the markup/product info and optimised meta data injected into the queue page, so that remains present at all points on the journey in the hope that this enables search engines to continue to rank and traffic the product page. What's your take on this? Any suggestions on how we might overcome the issues? (before you ask; avoiding using the queue system is impossible, sorry!) Thanks!1 -
Homepage with and without language subfolder
Hi all, We are checking to optimize a website that has four language versions in subfolders. When setting the self referencing canonicals and the hreflang tags, we came across a particular problem. Both the URL's example.com and example.com/nl are being indexed and have the same content in the same language. For the other language versions, it is quite straightforward, but what to do with these two URL's? Currently, there is a canonical tag from example.com to example.com/nl. Is a simple 301 redirect to the URL with the language subfolder the best solution? Something to consider: if a backlink points to example.com (without specifying the language subfolder), all the link juice will go to the /nl version and not to other versions (with a canonical as well as with a 301 of course). Thanks!
Intermediate & Advanced SEO | | Mat_C0 -
How to setup redirects
Hi Guys, If you're doing an SEO migration and have multiple versions of the same page example: Version 1: http://naturesway.com.au/superfood/super-maca-powder Version 2: https://naturesway.com.au/superfood/super-maca-powder Version 3: https://www.naturesway.com.au/superfood/super-maca-powder And you want to redirect them to a new URL (new site): New Site: https://www.naturesway.com.au/nw-superfoods-maca-powder-100g How would you ensure you redirect all the different versions of URL (versions 1,2,3) to the new URL on the new site? Cheers.
Intermediate & Advanced SEO | | brandonegroup0 -
Should I switch from trailing slash to no trailing slash?
I have a website which has had trailing slashes added to the URLs by 301 redirects for over 3 years. However, the custom CMS does not allow navigation links to have trailing slashes. This is resulting in 301s every time a user clicks a navigation link. The site ranks fairy well for some moderately competitive keywords. If you were in my shoes, would you remove the forced trailing slash redirect in the .htaccess and replace it with a trailing slash removal redirect, or would you leave it like it is? Thanks,
Intermediate & Advanced SEO | | ICON_Malta
James p.s. the CMS also doesn't allow canonicals.0 -
Trailing Slash and Non-Trailing Slash Inconsistency
Hi, Majority of the URLs on the site I'm working on are using non-trailing slash, https://example.com/page1
Intermediate & Advanced SEO | | nerdieb
https://example.com/page2
https://example.com/page3 But when it comes to the blog pages, they are using trailing slash: https://example.com/blog/specific-blog-post1/
https://example.com/blog/specific-blog-post2/
https://example.com/blog/specific-blog-pos3t/ Note that there is no duplication here since they have canonical tags. My only concern is that:
Is it okay to have this kind of structure where the blog page have trailing slash while the rest are using non-trailing slash? Keen to hear from you guys. Cheers!0 -
Redirect Plugin: Redirecting or Rewriting?
Hey everybody! It's been a while since off the boards! I am reworking a site and I have been looking into their Redirection Plugin. I personally tend to lean towards just using the .htaccess because, well, why not. However, when looking deeper into the plugin I found myself a little confused with their redirection wording. RewriteRule ^/products/landing-page-october-2015/$ /products/special-education-news-october-2015/ [R=301,L] Is that the same thing as a classic Redirect 301?
Intermediate & Advanced SEO | | HashtagHustler0 -
SEO direction - help needed
Hi, I've been working on a site for about 5 years. We built the traffic up to about 8k visitors/day. Although now it's dropped down over the past 2 years to about 2k visitors a day. New traffic source is mainly from SEO longtail. The whole time we have been working to improve the site. What's the best way to get some help from experts on the right direction to get traffic back up or to at least tell me the site will never work 🙂 Thanks in advance. M
Intermediate & Advanced SEO | | relientmark0 -
Help with https// redirects
Hey there
Intermediate & Advanced SEO | | Jay328
I have a client who just moved from a self hosted CMS to Adobe Catalyst (don't ask!)
The problem: Their url indexed with google is https://domain.com, Adobe Catalyst does not support third party SSL certificates or https domains. Now when people google them https://domain.com shows up in search, HOWEVER it does not have a trusted certificate and a pop up window blocks the site. They are a mortgage company so SSL is really not needed. What can I do to get google to recognize the site at http: vs. https? Would this be something in GWMT? Thanks!0