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
-
Would You Redirect a Page if the Parent Page was Redirected?
Hi everyone! Let's use this as an example URL: https://www.example.com/marvel/avengers/hulk/ We have done a 301 redirect for the "Avengers" page to another page on the site. Sibling pages of the "Hulk" page live off "marvel" now (ex: /marvel/thor/ and /marvel/iron-man/). Is there any benefit in doing a 301 for the "Hulk" page to live at /marvel/hulk/ like it's sibling pages? Is there any harm long-term in leaving the "Hulk" page under a permanently redirected page? Thank you! Matt
Intermediate & Advanced SEO | | amag0 -
URL structure with dash or slash
Hi, everyone Basically I am editing my website page's URL for SEO Optimisation and I am not sure which URL structure is best for SEO. The main different is the sign ( dash or slash ) before the product-code. HERE ARE TWO EXAMPLE www.example.com/long-tail-keyword-product-code www.example.com/long-tail-keyword/product-code To get more idea of my page, here is one of the product from my website : http://www.okeus.co.uk/pro_view-3.html My website is selling my own product, as a result the only keyword can be found was the name of the product and I separated different design by different code. Any experts who are willing help would be very much appreciated.
Intermediate & Advanced SEO | | chrisyu781 -
Help with force redirect HTTP to HTTPS
Hi, I'm unsure of where I should be putting the following code for one of my Wordpress websites so that they redirect all HTTP requests to HTTPS. RewriteEngine On RewriteCond %{HTTPS} !=on RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] This is my current htaccess file: *missing
Intermediate & Advanced SEO | | Easigrass0 -
Penguin and 301 redirects...
Hi, I have several questions about starting a new domain due to Penguin. The site is: http://bajajlaw.com. Quick backstory: This site was hit every time Penguin rolled out. No clean-up was done until October 2015. At that time, I took over the project. My efforts include: (1) Remove'em, (2) manual removal, (3) and the Disavow Tool. The HP went from being at around #50 for the target KW (San Diego criminal defense attorney) to about #25. Never really moved higher than that. However, I redid the content for the internal pages (DV, Theft Crimes, etc.) and they are all ranking fairly well (first page or top of 2nd). In short, the penalty only seems to affect the HP, not the internal pages. Instead of waiting for Penguin to roll-out, client wants to move forward with new domain. My questions are as follow: 1. Can I use the same content for the internal pages and 301 from the old internal pages to the new? 2. Should I 301 from the old to the new domain for the HP, or not? 3. If I do a 301 from an internal page to a new internal page, does that have the same effect of doing a 301 from the old HP to the new HP? I have read various opinions on this topic. I'd appreciate feedback from anyone who has experience doing this sort of thing. Thanks. P.s. I'm inclined to wait for P4 to rollout, but given that nobody seems to know when that might be, it's hard for me to advise client to keep waiting for it.
Intermediate & Advanced SEO | | mrodriguez14400 -
New Site (redesign) Launched Without 301 Redirects to New Pages - Too Late to Add Redirects?
We recently launched a redesign/redevelopment of a site but failed to put 301 redirects in place for the old URL's. It's been about 2 months. Is it too late to even bother worrying about it at this point? The site has seen a notable decrease in site traffic/visits, perhaps due to this issue. I assume that once the search engines get an error on a URL, it will remove it from displaying in search results after a period of time. I'm just not sure if they will try to re-crawl those old URLs at some point and if so, it may be worth it to have those 301 redirects in place. Thank you.
Intermediate & Advanced SEO | | BrandBuilder0 -
Help... To Optimize Category Page or Not?
My question is about whether to optimize a category page or not, but it’s a rather odd situation. Here’s a bit of background to start. When we relaunched our site, about six months ago, we had primary, secondary, and tertiary categories created. A user could reach all three levels by clicking through the site. Then we decided instead of linking to the tertiary categories, that we’d turn them into filters which can be applied at the secondary level. Thus, there is not actually a direct link to the 3rd level categories on the site. An important side note, I did check and confirm they are still included in the sitemap file. My initial thoughts were to forget any further optimization of those 3rd level categories, but as it turns out we still have rankings for some of them. Now the question… Because some of these pages are ranking and are found in the sitemap, should I include them in my SEO plan to build up and optimize, or because they are no longer linked to directly on the site will they eventually fizzle out (and I shouldn’t do anything further). This is such a unique situation that I am really looking for some insight from the community. Thanks!
Intermediate & Advanced SEO | | M_D_Golden_Peak0 -
Redirect advice
My website has two versions of the homepage: http://www.nile-cruises-4u.co.uk/http://www.nile-cruises-4u.co.uk/index.cfmI wondered if I could set up a 301 redirect in the .htaccess file so that only the http://www.nile-cruises-4u.co.uk page was returned as the homepage?Colin
Intermediate & Advanced SEO | | NileCruises0 -
Help me solve a keyword ranking mystery please
I posted this and had some help (thank you!) but found some new things, so I thought I'd just start a new thread so no info. is missed. Hi everyone, I'm new here 🙂 So far I've had wonderful success seo wise and none of the updates (Penguin nor Panda) affected any sites, until this one. For example, one site has 7 keywords I'm optimizing for. Out of those 7, all but 2 (and variations of the 2 - one word vs long-tail) completely tanked. These keywords were all on page 2/3. One of the two survivors never budged from page 2 (it's a brand keyword so I was very happy to finally get it to page 2) Now when I check rankings, the other terms show up in the 200-400 spots, but NOT for the URL I was optimizing for (category page) but instead for random products in the category. The only thing I've done differently with the 2 keywords that are still doing well, was focus - we did more link-building for those, but not an extreme amount. Never over-optimize. My question is, how did 2 survive and 5 are still floating up and down. Last night I saw one go up 122 spots, now today down 14. I'm really struggling with this. I just ran another diagnostic crawl here and the report found 0 errors and 0 warnings. I checked category content with a plagiarism checker and found some external duplicate content which I've already taken care of. No critical warnings/messages in WMT either. I'm stumped 😞 Thank you for any help.
Intermediate & Advanced SEO | | Freelancer130