友情URL(Mod Rewrite)无法在Parked Domains上运行

时间:2013-07-11 09:31:53

标签: php apache .htaccess mod-rewrite

我正在尝试设置友好的网址以使用托管域名。我有以下.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]

原则是,我希望http://www.example.co.uk/winhttp://www.example.com/win等任何网址加载页面http://www.example.com/container.php?page=winhttp://www.example.co.uk/gameshttp://www.example.com/games以加载页面{ {1}}。我还添加了排除图像,javascript,样式和包含目录的规则。

如果用户转到http://www.example.com/container.php?page=games,则会重定向到http://www.example.co.uk/index(.php or .htm or .html)

由于某些原因,我的代码无效。我不明白为什么不。任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:0)

你同时使用mod_alias和mod_rewrite,我不相信你需要排除你的静态内容,因为你唯一的路由4个静态条目。清理.htaccess文件并尝试一下。

RewriteEngine On

RewriteRule ^/$ http://www.example.com/home/
RewriteRule ^index.(html|php|htm)$ http://www.example.com/home/ 
RewriteCond  %{REQUEST_URI} !(images\/|styles\/|javascripts/|includes/) 
RewriteRule  ^([a-zA-Z]*)/$ http://www.example.com/container.php?page=$1 [P]
相关问题