开发者

Virtual Subdomains

开发者 https://www.devze.com 2023-02-15 07:22 出处:网络
I want to redirect wildcard subdomains to the file \"user_site.php\" like the following : RewriteCond $1 !^(user_site\\.php|home_site\\.php

I want to redirect wildcard subdomains to the file "user_site.php" like the following :

RewriteCond $1 !^(user_site\.php|home_site\.php    
RewriteCond %{HTTP_HOST} !^(www|mai开发者_开发问答l|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"

how can this be done ? Thanks


I've found it already answered here on stackoverflow , Thanks

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]
0

精彩评论

暂无评论...
验证码 换一张
取 消