htaccess mod_rewrite子域继承主域的规则

时间:2010-07-23 10:29:40

标签: apache .htaccess mod-rewrite url-rewriting

我希望将m.example.com重定向到example.com/index.php?type=mobile,同时继承我已经为example.com编写的规则......

所以,比如说,我已经定义了N个规则:

^view/([A-z]+) index.php?view=$1
^delete/([A-z]+) index.php?delete=$1
^page/view/([A-z]+)/([0-9]+) index.php?view=$1&page=$2
^page/delete/([A-z]+)/([0-9]+) index.php?delete=$1&page=$2

无需重写m.example.com子域的每一个,m.example.com是否有办法继承相同的规则,但子域标志为type=mobile?基本上,无需为位于m子域文件夹中的.htaccess添加N行:

^view/([A-z]+) index.php?view=$1&type=mobile
^delete/([A-z]+) index.php?delete=$1&type=mobile
^page/view/([A-z]+)/([0-9]+) index.php?view=$1&page=$2&type=mobile
^page/delete/([A-z]+)/([0-9]+) index.php?delete=$1&page=$2&type=mobile

2 个答案:

答案 0 :(得分:1)

答案 1 :(得分:0)