gpt4 book ai didi

apache - RewriteCond 反向引用不起作用

转载 作者:行者123 更新时间:2023-12-04 07:03:04 28 4
gpt4 key购买 nike

如果我去http://www.example.com我希望它留在那里,这工作正常。
如果我去http://bar.example.com它重定向到 http://www..com ,这是错误的
想要http://www.example.com鉴于 RewriteCond 中的反向引用

重写引擎开启

RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www.(example).com [NC]
重写规则 ^(.*) http://www.%1.com/$1 [L,R]

Ubuntu 8.04
包:apache2-mpm-prefork
架构:i386
版本:2.2.8-1

最佳答案

否定模式没有匹配项,因此您不能引用一组不存在的匹配项。

但是试试这个规则:

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

关于apache - RewriteCond 反向引用不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1535485/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com