无限重定向循环htaccess

时间:2016-06-07 11:58:49

标签: apache .htaccess redirect

我想重定向每个www。 url到没有www的网址。使用.htaccess但我得到一个无限重定向循环。

有人看到我做错了吗?

RewriteEngine  on
RewriteBase /_extern/pod/
RewriteCond %{HTTP_HOST} !^site\.nl/_extern/pod/$ [NC]
RewriteRule ^(.*)$ http://site.nl/_extern/pod/$1 [R=301,L]

#Indexes uitzetten
Options -Indexes

#Cross site access toestaan
Header set Access-Control-Allow-Origin "*" 
Header add Access-Control-Allow-Headers "origin, x-requested-with, content-type" 

#POD
DirectoryIndex index.php

RewriteRule         ^info/(.*).html catlisting.php?alias=$1 [L]
RewriteRule         ^nieuws/(.*).html nieuws.php?alias=$1 [L]
RewriteRule         ^(.*).html content.php?alias=$1 [L] 

site.nl/extern/pod/需要成为所有网址的根目录。

我的基准标签是否相关:

<base href="http://site.nl/_extern/pod/">

1 个答案:

答案 0 :(得分:2)

在我看来,您对某些目录的URL非常具体,请尝试使用以下内容:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1%{REQUEST_URI} [R=301,QSA,NC,L]

因此,这应该从您的所有网址和子目录中删除WWW