0
我需要添加一些重写规则到网站。需要apache重写规则帮助
这里的想法=>
重写从
(http or https)://(www. or no www.)example.com/whatever
(http or https)://www.example.com/whatever
所有非子域交通(所以基本上,总是强迫WWW)
此外重写仅此1 sumbdomain =>
(http or https)://(www. or no www.)store.example.com/whatever
(http or https)://www.example.com/whatever
保留所有其他的s ubdomains完好无损。
到目前为止,我有这个=>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com$
RewriteCond %{HTTP_HOST} ^store.example.com$
RewriteRule ^(.*)$ http%{ENV:askapache}://www.example.com/$1 [R=301,L]
但它无法正常运行......
任何帮助将appriciated。
谢谢!
非常感谢您的投入,但我得到了“此网页有重定向循环”错误http://store.example.com/httpstore。://www.example.com .... – Andrej
这是怎么回事,因为重定向的URI有主机www.example.com',这会导致这种情况失败:'RewriteCond %{HTTP_HOST} ^(store \。)?example \ .com $ [NC]'。你在.htaccess中还有其他的东西吗? – anubhava
我做了一些小改动,你现在可以尝试编辑的代码吗? – anubhava