Forum Moderators: phranque
Have had a blog for over a year and it tends to do technical stuff on autopilot but have just found a redirect loop in a category link in Wordpress and am totally stuck.
the URLs are identical and I have no idea where it is coming from or how to fix it ... spent all day searching blogs and forums but none the wiser.
I am using the redirection plugin and have not created a redirect for that URL. When I deactivate the plugin the category link works fine but then I get 404 errors on my redirected posts.
I don't even know what the .htaccess file does and have never opened it, so I didn't change anything in there.
Have read lots of things saying to clean up the .htaccess file as they become very big but I just checked and this is all mine says:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>
# END WordPress
Please can anyone shed some light on this before I end up bald.
Thank you
Your code says:
# (Comment line) BEGIN WordPress
# If mod_rewrite is installed, begin conditional code
<IfModule mod_rewrite.c>
# Turn on the rewriting engine
RewriteEngine On
# Set the rewritebase to /blog/
RewriteBase /blog/
# If the requested URL does not resolve to an existing file
RewriteCond %{REQUEST_FILENAME} !-f
# and if the requested URL does not resolve to an existing directory
RewriteCond %{REQUEST_FILENAME} !-d
# then rewrite all requested URLs except for your home page URL to (the WP script at) /blog/index
RewriteRule . /blog/index.php [L]
# end of conditional code
</IfModule>
Here's a guess: Take a look at your plugin "redirect" definitions. You are probably looking for one of two things:
1) If your server redirects all requests for example.com to www.example.com, then make sure that all of your "redirects" target URLs in www.example.com. If not, then you could get a loop.
If your server redirects all requests for www.example.com to example.com, then make sure that all of your "redirects" target URLs in example.com. If not, then you could get a loop.
2) If you have two "redirects" which countermand each other, i.e. one says "redirect URL "/abc" to URL "/def" and the other says "redirect URL "/def" to URL "/abc", then you will get a loop.
If this investigation is non-productive, then download and install the "Live HTTP Headers" add-on for Firefox and Mozilla browsers, and test your looping scenario while monitoring the transactions between your browser and your server. This add-on will clearly show the server's redirect responses (301 or 302 status codes). If the problem isn't obvious from looking at the (probably two) URLs that are (probably) redirecting to each other, then post the browser request lines and the server response lines here. These will look like:
---
Client request:
GET /abc HTTP/1.1
Server response:
HTTP/1.x 301 Moved Permanently (could also be "302 Found or "302 Moved Temporarily")
Location: http://www.example.com/def
---
Client:
GET /def HTTP/1.1
Server:
HTTP/1.x 301 Moved Permanently
Location: http://www.example.com/abc
---
Client:
GET /abc HTTP/1.1
Server:
HTTP/1.x 301 Moved Permanently
Location: http://www.example.com/def
---
Client:
GET /def HTTP/1.1
Server:
HTTP/1.x 301 Moved Permanently
Location: http://www.example.com/abc
---
etc...
As illustrated here, abc redirects to def, which redirects back to abc, creating a loop.
The Live HTTP Headers add-on will report many other request and response headers for the looping URLs. You can ignore them at this stage, and only post the lines that look like the ones above. Also, please change the URLs you post to remove any information that may be used to identify (or to compromise) your site. Use "example.com" as the domain, and change any obviously-identifiable URLs to something more generic -- For example, "model-airplanes.html" to "model-widgets.html" or similar...
Jim
Thanks so much for your quick response.
I have not set a redirect on that URL so for some reason it is being done automatically but I'm blowed if I can understand how, why or where.
Have made the changes to stop it being identified.
http://www.example.co.uk/blog/category/about-dogs/
GET /blog/category/about-dogs/ HTTP/1.1
HTTP/1.x 301 Moved Permanently
Location: /blog/category/about-dogs/
GET /blog/category/about-dogs/ HTTP/1.1
HTTP/1.x 301 Moved Permanently
Location: /blog/category/about-dogs/
GET /blog/category/about-dogs/ HTTP/1.1
HTTP/1.x 301 Moved Permanently
Location: /blog/category/about-dogs/
Thank you for your time
[edited by: jdMorgan at 12:56 pm (utc) on May 12, 2009]
[edit reason] example.com.uk [/edit]