从.htaccess获取子域名中的任何地址

时间:2014-02-19 02:26:06

标签: php apache .htaccess

我想从子域名获取任何URL到root(mvc boot)

我在此代码中使用根文件夹:

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ boot.php?url=$1 [L]
#this code good working ... 

但是对于子域名,我如何获取不存在的文件?

#The following code is worked,but not get 404 folders Or files(!-d,!-f,!-l)
RewriteCond %{HTTP_HOST}  ^mySubDomain.domain.com [OR]
RewriteRule ^(.*)$ /../boot.php?url=$1 [L] 

我如何添加:

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l

这段代码?

1 个答案:

答案 0 :(得分:0)

我解决了这个问题 ...

我在子域目录中创建.htaccess文件并将此代码添加到.htaccess

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ /../boot.php?url=$1 [L]