redirect subdomain to same subdomain name but different domain name

﹥>﹥吖頭↗ 提交于 2019-12-06 11:22:19

This may work. Put it in your .htaccess.

RewriteEngine On
RewriteCond %{HTTP_HOST} (.*).example.com
RewriteRule (.*) http://%1.example.net/$1 [R=301,QSA,L]

Haven't tested it, but it should give you a start.

Use %1 %2 etc. to grab regex-match groups from the RewriteCond.

As you probably know, $1 $2 matches regex groups from the RewriteRule

Off the top of my head, this is pretty straightforward with mod_rewrite active:

 RewriteEngine On
 RewriteCond %{REQUEST_HOST} (.+)\.example\.com
 RewriteRule (.*) http://%1.example.net$1 [R,QSA]

This assumes that you are serving all those subdomains from a single virtual host, but if you aren't, you can just copy this ruleset into each one's config or .htaccess individually.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!