2013-12-20 78 views

回答

0

尝试在staging目录添加此规则的htaccess文件:

RewriteEngine On 
RewriteCond %{HTTP_HOST} ^(www\.)?mydomain\.com$ [NC] 
RewriteRule ^(.*)$ http://staging.mydomain.com/$1 [L,R] 
+0

这伟大的工作。当我在cPanel中尝试这个时,它给了我一个错误:'你不能将“登台”重定向到“http://staging.mydomain.com”,因为这会导致重定向循环,因为“/ home/[username]/public_html/staging“与”/ home/[username]/public_html/staging“位于相同的位置。你的代码如何防止这一点? – cusejuice

+1

你把代码放在'staging'目录下吗?这就是你阻止循环的原因,因为URI的'/ staging /'部分被剥离了。 –

+0

是的,我把它放在'staging'目录中,它工作。只是好奇,为什么它不是从我的cPanel工作。谢谢! – cusejuice

0

您可以在/staging/.htaccess试试这个代码:

RewriteEngine On 
RewriteBase /staging/ 

RewriteCond %{HTTP_HOST} ^(www\.)?mydomain\.com$ [NC] 
RewriteRule ^(.*)$ http://staging.mydomain.com/$1 [L,NE,R=301] 
相关问题