2015-09-07 22 views
0

我想補充public/index.php所有請求,但它並沒有改變。 。

實施例:

如果i型

localhost/project/first 

就應請

localhost/project/public/index.php/first 

什麼是我.htaccess的問題?

+1

刪除模式中的前導斜槓。 – starkeen

+0

你的意思是這樣的? https://eval.in/429241 –

回答

1

可以在/project/.htaccess使用這樣的規則:

RewriteEngine On 
RewriteBase /project/ 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ public/index.php/$1 [L] 

這是/project/public/.htaccess

<IfModule mod_negotiation.c> 
    Options -MultiViews 
</IfModule> 

RewriteEngine On 
RewriteBase /project/public/ 

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

# Redirect Trailing Slashes... 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.+?)/$ /$1 [L,R=301,NE] 

# Handle Front Controller... 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule^index.php [L] 

RewriteCond需要避免重寫真正的文件和目錄。並且在.htaccess中不應該有RewriteRule模式中的任何前導斜槓。 .htaccess是每個目錄指令,並且Apache從RewriteRule URI模式剝離當前目錄路徑(因此引導斜槓)。

+0

謝謝,有一個名爲'公共'..文件夾下的另一個.htaccess ..這裏是..https://eval.in/429259會影響這一個.. bcoz這是沒有正確請求.. –

+0

這個.htaccess位於何處? – anubhava

+0

這是在根本上,即'localhost/project/.htaccess'裏面 –

相關問題