0

我使用 cPanel 的设置:

  1. domain.com(/public_html/)
  2. mysub.domain.com(/public_html/2013/sitepath/)

目标:让 sub2.mysub.domain.com/save-path-info 重定向到 mysub.domain.com/save-path-info 而不更改来自 sub2.mysub.domain.com 的 url。换句话说,我希望 anysub.mysub.domain.com 与 mysub.domain.com 几乎完全相同。

代码:

 Options +FollowSymLinks
 Options +Indexes
 RewriteEngine On
 RewriteCond %{ENV:REDIRECT_STATUS} ^$
 RewriteCond %{HTTP_HOST} !^www\.2013.cqueue\.com$ [NC]
 RewriteCond %{HTTP_HOST} ^(www\.)?([^\.]+)\.2013.cqueue\.com$ [NC]
 RewriteRule (.*) /2013/sitepath/$1 [L]

上面的代码最初位于 mysub.domain.com 的根目录中,但直到我将其移至 domain.com 的根目录后才起作用。它成功地保留了 URL 和路径,但是它破坏了我的模板的相对路径。

示例:模板通常会查找/的路径,但是通过上面的重写,模板认为他们需要查找 /2013/sitepath/

编辑

 Options +FollowSymLinks
 Options +Indexes
 RewriteEngine On
 RewriteCond %{HTTP_HOST} ^[^\.]+\.mysub\.domain\.com$ [NC]
 RewriteRule ^(.*)$ http://mysub.domain.com/$1 [L]

 # -FrontPage-

 IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*

 <Limit GET POST>
           order deny,allow
 deny from all
 allow from all
 </Limit>
 <Limit PUT DELETE>
           order deny,allow
      deny from all
 </Limit>
      AuthName domain.com
 AuthUserFile /home/uadmin/public_html/_vti_pvt/service.pwd
 AuthGroupFile /home/uadmin/public_html/_vti_pvt/service.grp
4

1 回答 1

0

试试这个代码:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^[^\.]+\.mysub\.domain\.com$ [NC]
RewriteRule ^(.*)$ http://mysub.domain.com/$1 [L]
于 2013-07-18T17:42:49.490 回答