重写规则中的无限循环:如何防止URL中的www?

时间:2022-11-24 08:31:42

I'd like my site to be accessible by the following two urls only:

我希望我的网站只能通过以下两个网址访问:

http://domain.com
http://origin.domain.com

But the following rewrite rule gets into an infinite loop:

但是下面的重写规则进入了一个无限循环:

RewriteCond %{HTTP_HOST} !^(origin)\.domain\.com [NC]
RewriteRule (.*) http://domain.com$1 [R=301,L]

What am I doing wrong? Any help would be greatly appreciated!

我究竟做错了什么?任何帮助将不胜感激!

1 个解决方案

#1


1  

Change the first line to

将第一行更改为

RewriteCond %{HTTP_HOST} !^(origin)?\.?domain\.com [NC]

#1


1  

Change the first line to

将第一行更改为

RewriteCond %{HTTP_HOST} !^(origin)?\.?domain\.com [NC]