如何解决过多造成的.htaccess重定向? [英] How can I fix too many redirects caused by .htaccess?

查看:593
本文介绍了如何解决过多造成的.htaccess重定向?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近增加了一个字preSS博客到客户的网站。我创建一个子目录,并安装了Word preSS那里。一切工作正常,直到我添加了一个.htaccess文件到根目录。

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.

有谁知道如何解决这个问题?我一点也不熟悉的.htaccess。

Does anybody know how to fix this problem? I'm not at all familiar with .htaccess.

编辑:只是要清楚,301重定向工作正常,所有的页面,除了博客文件夹。如果您在输入websitename.com,您重定向到www.websitename.com。但是,如果你输入websitename.com/blog你会遇到的错误。在这个例子中的博客指向一个字preSS的文件夹中。

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.

推荐答案

我想你正在试图迫使WWW。

I take it you are trying to force "www."?

使用以下内容:

RewriteCond %{HTTP_HOST} ^suncoastlaw\.com
RewriteRule .* http://www.%{SERVER_NAME}%{REQUEST_URI} [R,L]

要得到一点点的详细信息,请查看我写到这里的帖子:强制WWW

To get a little bit more info, check out the post I wrote here: Forcing www

这篇关于如何解决过多造成的.htaccess重定向?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆