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

WBOY
Freigeben: 2016-06-06 20:37:41
Original
1646 Leute haben es durchsucht

目前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

Verwandte Etiketten:
Quelle:php.cn
Erklärung dieser Website
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage
Über uns Haftungsausschluss Sitemap
Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!