将 url 重写为非 www 多个站点
我有一些网站正在使用相同的文件但不同的模板运行,我的目标是强制使用所有 www 或非 www 域。
这是我的代码:
RewriteCond %{HTTPS} (on)?
RewriteCond %{HTTP:Host} ^(?!www\.)(.+)$ [NC]
RewriteCond %{REQUEST_URI} (.+)
RewriteCond %{HTTP:Host} ^[^.]+\.[a-z]{2,5}$ [NC]
RewriteRule .? http(?%1s)://www.%2%3 [R=301,L]
从 stackoverflow 上的其他问题获取它:)
但是如果我使用 www 域一切都可以,如果没有得到此重定向
http://domain.de/www/htdocs/user/_products/http% 28?s%29://www.
i have some sites they are running with the same files but different templates, my goal is to force use all www or non www domains.
this is my code:
RewriteCond %{HTTPS} (on)?
RewriteCond %{HTTP:Host} ^(?!www\.)(.+)$ [NC]
RewriteCond %{REQUEST_URI} (.+)
RewriteCond %{HTTP:Host} ^[^.]+\.[a-z]{2,5}$ [NC]
RewriteRule .? http(?%1s)://www.%2%3 [R=301,L]
get it from other question on stackoverflow :)
But if I use www domain all is ok, if not get this redirect
http://domain.de/www/htdocs/user/_production/http%28?s%29://www.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为什么不像这样简化你的规则:
Why not simplify your rules like this: