我正在尝试设置友好的 URL 来处理停放的域。我有以下 .htaccess 文件:
RewriteEngine On
RedirectMatch ^/$ http://www.example.com/home/
RedirectMatch ^/[index.php|index.html|index.html]$ http://www.example.com/home/
RewriteCond %{REQUEST_URI} ^/home[/]*$
RewriteRule ^/home[/]*$ http://www.example.com/container.php?page=index [P]
RewriteCond %{REQUEST_URI} [a-z]*[|/](images|styles|javascripts|includes)(.*)
RewriteRule [a-z]*[|/](images|styles|javascripts|includes)(.*) http://www.example.com/$1/$2 [P]
RewriteCond %{REQUEST_URI} !(images/|styles/|javascripts/|includes/)
RewriteRule ([a-z]*)[/]$ http://www.example.com/container.php?page=$1 [P]
RewriteCond %{HTTP_HOST} ^example\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.example\.com$
RewriteRule ^/?$ "http\:\/\/www\.example\.com\/home\/" [R=301,L]
原则是,我想要任何 URL http://www.example.co.uk/win
,http://www.example.com/win
加载页面http://www.example.com/container.php?page=win
或加载页面。我还添加了排除图像、javascript、样式和包含目录的规则。http://www.example.co.uk/games
http://www.example.com/games
http://www.example.com/container.php?page=games
如果用户去,http://www.example.co.uk/index(.php or .htm or .html)
那么它将重定向到http://www.example.com/home/
.
出于某种原因,我的代码无法正常工作。我不明白为什么不。任何帮助将不胜感激。