I recently added a Wordpress blog to a client's website. I create a subdirectory and installed Wordpress there. Everything worked fine until I added a .htaccess file to the root directory.
RewriteEngine on
rewritecond %{http_host} ^websitename.com [nc]
rewriterule ^(.*)$ http://www.websitename.com/$1 [r=301,nc]
Now, when I click on the blog link I get the following error
The webpage at http://websitename.com/blog/ has resulted in too many redirects.
Clearing your cookies for this site or allowing third-party cookies may fix the problem. If not, it is possibly a server configuration issue and not a problem with
your computer.
Does anybody know how to fix this problem? I'm not at all familiar with .htaccess.
Edit: Just to be clear, The 301 redirect works fine for all of the pages, Except for the blog folder. If you type in websitename.com, your redirected to www.websitename.com. However if you type in websitename.com/blog you will encounter the error. The blog in in this example points to a Wordpress folder.
Simply remove the lines from your . htaccess . In case it does not work your browser may have cached the 301 redirect, as it is meant to be permanent. Try restarting your browser or use a another browser to check whether it worked.
The reason you see the “too many redirects” error is because your website has been set up in a way that keeps redirecting it between different web addresses. When your browser tries to load your site, it goes back and forth between those web addresses in a way that will never complete — a redirect loop.
I take it you are trying to force "www."?
Use the following:
RewriteCond %{HTTP_HOST} ^suncoastlaw\.com
RewriteRule .* http://www.%{SERVER_NAME}%{REQUEST_URI} [R,L]
To get a little bit more info, check out the post I wrote here: Forcing www
you want *.suncoastlaw.com/xx -> www.suncoastlaw.com/xx
do you ?
then your conf
^(.*)$ http://www.suncoastlaw.com/$1
let www.suncoastlaw.com/$1 301-> www.suncoastlaw.com/$1
so there would be too many redirect
change to
rewritecond %{http_host} !www.suncoastlaw.com
when not www.suncoastlaw.com then redirect
all the rewrite conf detail could be found at
http://httpd.apache.org/docs/current/mod/mod_rewrite.html
how to trace
your http://suncoastlaw.com/blog/ redirect to http://www.suncoastlaw.com/blog/ and then http://www.suncoastlaw.com/blog/ redirect to http://suncoastlaw.com/blog/ this is the problem
$ curl -I http://suncoastlaw.com/blog/
HTTP/1.1 302 Found
Date: Sat, 26 Jan 2013 13:37:10 GMT
Server: Apache
Location: http://www.suncoastlaw.com/blog/
Content-Type: text/html; charset=iso-8859-1
$ curl -I http://www.suncoastlaw.com/blog/
HTTP/1.1 301 Moved Permanently
Date: Sat, 26 Jan 2013 13:37:21 GMT
Server: Apache
X-Pingback: http://suncoastlaw.com/blog/xmlrpc.php
Location: http://suncoastlaw.com/blog/
Content-Type: text/html; charset=UTF-8
Try adding these lines to your httpd.conf file instead of using .htaccess file to force WWW sub-domain:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^(127\.0\.0\.0|localhost) [NC]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}$1 [L,R=301]
You might also want to add your IP in the list of the second line, if you'll be accessing your web server by IP only. For a bit more explanation also read the answer in this thread ;)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With