简体   繁体   English

虚拟子域

[英]Virtual Subdomains

I want to redirect wildcard subdomains to the file "user_site.php" like the following : 我想将通配符子域重定向到文件“ user_site.php”,如下所示:

RewriteCond $1 !^(user_site\.php|home_site\.php    
RewriteCond %{HTTP_HOST} !^(www|mail|ftp)?\.?domain.com [NC]
RewriteRule ^(.*)$ /user_site.php/$1 [L]

but if the subdomain is www or empty , i want to rewrite it to "home_site.php" 但是,如果子域名是www或为空,我想将其重写为“ home_site.php”

how can this be done ? 如何才能做到这一点 ? Thanks 谢谢

I've found it already answered here on stackoverflow , Thanks 我已经在stackoverflow上找到了答案,谢谢

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{HTTP_HOST} ^(www\.)?domain.com$ [NC]
RewriteRule ^(.*)/?$ home_site.php/$1 [NC,QSA,L]

RewriteCond %{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_URI} ^/index.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{HTTP_HOST} !^(www|mail).domain.com$ [NC]
RewriteCond %{HTTP_HOST} ^(www\.)?([a-z0-9-]+).domain.com$ [NC] 
RewriteRule ^(.*)/?$ user_site.php/$1 [NC,QSA,L]

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

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