简体   繁体   中英

Redirecting to a specific file from all subdomains using htaccess

我想在用户请求a.domain.com/index.php或b.domain.com/index.php时将流量重定向到特定文件,它会重定向到domain.com/index.php

You can use this code in your DOCUMENT_ROOT/.htaccess file:

RewriteEngine On

RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} ^[^.]+\.domain\.com$ [NC]
RewriteRule ^(index\.php)$ http://domain.com/$1 [L,NC,R]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM