【发布时间】:2011-11-30 00:54:50
【问题描述】:
我有一个网站,可以使用“www”和不使用“www”访问它(例如 www.example.com 和 example.com )。如果 URL 中没有“www”,则 mod_rewrite 用于重定向到 www.example.com。
但是,如果我去 example.com/something.html,它会被重定向到 www.example.com(something.html 被截断)。
目前,我的规则是:
<VirtualHost *:80>
ServerName example.com
RewriteEngine On
RewriteRule /.* http://www.example.com [R]
</VirtualHost>
使重写递归和使 example.com/something.html 重定向到 www.example.com/something.html 的最简单方法是什么
【问题讨论】:
-
很难相信以前没有人问过这个问题.....(提示:搜索
mod_rewrite prepend www)
标签: apache mod-rewrite web no-www