URL重写 根据域名显示不同内容

WBOY
发布: 2016-06-06 20:37:41
原创
1645 人浏览过

目前apache伪静态URL重写.htaccess里是下面规则:
http://www.abc.com ---> index.php
http://www.abc.com/late/ ---> ./filedir/late.php?p=1
http://www.abc.com/popular/ ---> ./filedir/popular.php?p=1
http://www.abc.com/down/name-id/ ---> ./filedir/detail.php?id=number
http://www.abc.com/cat/catname-catid/ ---> ./filedir/cat.php?catid=number

http://www.abc.com/bb ---> ./filedir/bb.php
http://www.abc.com/bblate/ ---> ./filedir/bblate.php?p=1
http://www.abc.com/bbpopular/ ---> ./filedir/bbpopular.php?p=1
http://www.abc.com/bdown/name-id/ ---> ./filedir/bbdetail.php?id=number
http://www.abc.com/bcat/bcatname-catid/ ---> ./filedir/bbcat.php?bbcat.php?catid=number

现要增加一个二级域名bb.abc.com也指向www.abc.com服务器,并将域名后路径改为和www.abc.com形式相同,即
http://bb.abc.com ---> ./filedir/bb.php
http://bb.abc.com/late/ ---> ./filedir/bblate.php?p=1
http://bb.abc.com/popular/ ---> ./filedir/bbpopular.php?p=1
http://bb.abc.com/down/name-id/ ---> ./filedir/bbdetail.php?id=number
http://bb.abc.com/cat/bcatname-catid/ ---> ./filedir/bbcat.php?bbcat.php?catid=number

这要如何写.htaccess的URL重写规则呢?根据判断域名显示不同内容

URL重写 根据域名显示不同内容

回复内容:

目前apache伪静态URL重写.htaccess里是下面规则:
http://www.abc.com ---> index.php
http://www.abc.com/late/ ---> ./filedir/late.php?p=1
http://www.abc.com/popular/ ---> ./filedir/popular.php?p=1
http://www.abc.com/down/name-id/ ---> ./filedir/detail.php?id=number
http://www.abc.com/cat/catname-catid/ ---> ./filedir/cat.php?catid=number

http://www.abc.com/bb ---> ./filedir/bb.php
http://www.abc.com/bblate/ ---> ./filedir/bblate.php?p=1
http://www.abc.com/bbpopular/ ---> ./filedir/bbpopular.php?p=1
http://www.abc.com/bdown/name-id/ ---> ./filedir/bbdetail.php?id=number
http://www.abc.com/bcat/bcatname-catid/ ---> ./filedir/bbcat.php?bbcat.php?catid=number

现要增加一个二级域名bb.abc.com也指向www.abc.com服务器,并将域名后路径改为和www.abc.com形式相同,即
http://bb.abc.com ---> ./filedir/bb.php
http://bb.abc.com/late/ ---> ./filedir/bblate.php?p=1
http://bb.abc.com/popular/ ---> ./filedir/bbpopular.php?p=1
http://bb.abc.com/down/name-id/ ---> ./filedir/bbdetail.php?id=number
http://bb.abc.com/cat/bcatname-catid/ ---> ./filedir/bbcat.php?bbcat.php?catid=number

这要如何写.htaccess的URL重写规则呢?根据判断域名显示不同内容

URL重写 根据域名显示不同内容

找到方法:
RewriteCond %{http_host} ^bb.abc.com$
RewriteRule ^(/)?$ ./filedir/bb.php [L]
RewriteCond %{http_host} ^bb.abc.com$
RewriteRule ^late/$ ./filedir/bblate.php?p=1 [L]

同样谢谢 nathan_wu

serveralias bb.abc.com

相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!