使用apache将所有子域路径重定向到另一个子域

时间:2017-06-15 17:17:52

标签: apache redirect

今天我想将我创建的子域的所有路径重定向到使用我的私有服务器的另一个子域,但我想用APACHE而不是使用WHM。

这是我想要获得的: 我想重定向(转发)所有这些子域:

mysubdomain.mydomain.com/
mysubdomain.mydomain.com/path/
mysubdomain.mydomain.com/path/anotherpath/

myothersubdomain.mydomain.com/

我试过了:

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{http_host} ^mysubdomain.mydomain.com/path/anotherpath/ [nc]
RewriteRule ^(.*)$ myothersubdomain.mydomain.com/$1 [r=301,nc]

RewriteEngine on
RewriteCond %{HTTP_HOST} ^mysubdomain.mydomain.com/path/anotherpath/
RewriteRule ^(.*)$ myothersubdomain.mydomain.com/$1

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^mysubdomain.mydomain.com/path/anotherpath/$ [NC]
RewriteRule ^ myothersubdomain.mydomain.com%{REQUEST_URI} [R,L]

我的第一个子域名末尾是否需要一种通配符?

更新:

所有这些片段都没有发生。我希望我的用户可以从以下位置重定向:

mysubdomain.mydomain.com/path/anotherpath /

myothersubdomain.mydomain.com /

当他/她点击链接 mysubdomain.mydomain.com/path/anotherpath / 时。目前,最终用户仍然可以看到 mysubdomain.mydomain.com/path/anotherpath / 的内容。

0 个答案:

没有答案