2016-11-22 41 views
1

刪除一個字,我有一個項目的目錄結構如下的.htaccess - 從URL

| project 
--| controllers 
--| views 
    --| index.php 
    --| .htaccess 
--| config 
--| .htaccess 

這是我主要的.htaccess

<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteRule ^(.*)?$ views [L] 
</IfModule> 

和我的觀點的.htaccess

<IfModule mod_rewrite.c> 
    RewriteEngine on 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteRule ^.+$ index.php [L] 
</IfModule> 

我可以將所有請求重定向到views/index.php。當我去www.example.com/project將被重定向到www.example.com/project/views

我的主要問題是我不想在我的URL中有意見。如果我訪問www.example.com/project,它應該執行views/index.php,但URL不會更改。任何人都可以幫我弄清楚這個問題嗎?

回答

1

記住這主要的.htaccess:

RewriteEngine On 
RewriteRule .* views/$0 [L] 

然後有像這樣在.views/.htaccess

RewriteEngine on 

RewriteRule ^index\.php$ - [L,NC] 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule^index.php [L] 
+1

感謝的人。這工作。 –