【发布时间】:2013-10-07 05:01:33
【问题描述】:
你好,我有一个网站,有一个主域和子域.. 在 apache web 服务器和 centOS 上运行......我还有一个 url 重写机制,例如
http://subdomain.domain.com/buy-a-new-car
我想将所有子域请求重定向到主域,保持 url 重写如下:
http://domain.com/buy-a-new-car
我目前拥有的 .htaccess 代码导致:
http://domain.com/index.php?buy-a-new-car
id 喜欢去掉 (index.php?) 部分,但我是编写 .htaccess 指令的新手,并且被 REGEX 弄糊涂了
这是我当前的代码:
RewriteEngine on
RewriteBase /
Options -Indexes
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?/$1
RewriteCond %{HTTP_HOST} ^subdomain.domain.com$
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
任何帮助将不胜感激!
【问题讨论】:
标签: regex apache .htaccess mod-rewrite