简体   繁体   English

使用htaccess从所有子域重定向到特定文件

[英]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: 您可以在DOCUMENT_ROOT/.htaccess文件中使用此代码:

RewriteEngine On

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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