如何修复由.htaccess引起的过多重定向?

Mik*_*der 7 .htaccess redirect

我最近在客户的网站上添加了一个Wordpress博客.我创建了一个子目录并在那里安装了Wordpress.一切正常,直到我将.htaccess文件添加到根目录.

RewriteEngine on
rewritecond %{http_host} ^websitename.com [nc]
rewriterule ^(.*)$ http://www.websitename.com/$1 [r=301,nc] 
Run Code Online (Sandbox Code Playgroud)

现在,当我点击博客链接时,我收到以下错误

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.
Run Code Online (Sandbox Code Playgroud)

有人知道如何解决这个问题吗?我对.htaccess一点也不熟悉.

编辑:为了清楚起见,301重定向适用于所有页面,博客文件夹除外.如果您输入websitename.com,则会重定向到www.websitename.com.但是,如果您输入websitename.com/blog,您将遇到错误.此示例中的博客指向Wordpress文件夹.

The*_*ngK 5

我认为您是要强制使用“ www。”吗?

使用以下内容:

RewriteCond %{HTTP_HOST} ^suncoastlaw\.com
RewriteRule .* http://www.%{SERVER_NAME}%{REQUEST_URI} [R,L]
Run Code Online (Sandbox Code Playgroud)

要获取更多信息,请查看我在这里写的帖子:强制www