我有主域,例如domain.com,我需要重写另一个到url,例如如果域不是domain.com并且域是http://www.yyaa.com/say将其重写为 http://domain.com/index.php?p=say
RewriteEngine on
RewriteBase /
RewriteRule (.*) http://domain.tld/dashboard/$1 [P,QSA,L]
最佳答案
在执行重定向之前,使用 RewriteCond
检查所使用的域名是否不等于 domain.com
:
RewriteCond %{HTTP_HOST} !^domain\.com
RewriteRule (.*) http://domain.com/index.php?p=$1 [L,R=301]
关于php - 将域名重写为 url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9125841/