2014-01-18 41 views
0

我有一個網站的子目錄,在它的.htaccess:重寫規則相對子目錄中的htaccess的是

www.example.com/projA 
/var/www/html/projA/.htaccess 

我想所有www.example.com/projA/*我的文件重定向在/var/www/html/projA/index.php

我目前擁有的以下,其工作原理:

RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule . /projA/index.php [L] 

但因爲我的.htaccess文件已經是projA文件夾內,有沒有寫這個規則,以便日的方式在我根本不需要參考projA?例如。如果基本路徑可能是相對的.htaccess的位置,我只是想說明這一點:

RewriteRule . ./index.php [L] 

我不想引用「projA」,因爲它是可以經常改變的路徑。

回答

0

通過將htaccess放入projA文件夾並在重寫規則中使用相對路徑,可以刪除對projA的引用。 將你的htaccess放入/var/www/html/projA/.htaccess

RewriteEngine on 
# enable the following line if you want to serve directories directly (without index.php) 
#RewriteCond %{REQUEST_FILENAME} !-d 
# enable the following line if you have any other files on you want to serve directly 
#RewriteCond %{REQUEST_FILENAME} !-f 

RewriteCond %{REQUEST_FILENAME} !=index.php 

RewriteRule ^(.*)$ index.php/$1 [NC,QSA]