2014-07-14 46 views
1

我正在研究yii框架,並嘗試從url(httpx:// localhost:801/index.php/aImages)中刪除index.php,它應該是這樣的httpx:// localhost:801/aImages。所以下面給出的代碼在我的.htaccess文件中。此代碼在我的本地主機上工作,但不在我的團隊成員機器上工作。如何使用.htaccess從網址中刪除index.php

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

RewriteRule中的[L]是什麼。 /index.php [L]'? – tinybyte

+0

[如何在Yii框架中刪除index.php]的可能重複(http://stackoverflow.com/questions/9633649/how-to-remove-index-php-in-yii-framework) – topher

回答

4

嘗試:

Options +FollowSymLinks 
IndexIgnore */* 
RewriteEngine on 

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

RewriteRule . index.php 

,並在你的配置文件,使用:

... 
'urlFormat'=>'path', 
'showScriptName'=>false, 
... 
1

您需要創建.htaccess文件

RewriteEngine On 
RewriteBase/
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)\?*$ index.php/$1 [L,QSA] 

您可以檢查here進一步參考, NCE。

+0

感謝nana.chorage你回覆真的很有用,實際上rewrite_module不起作用,你提供的鏈接確實有幫助。 –

0

試試這個規則

RewriteRule ^index\.php/$ $1 [R=301,L] 
0

最後一行應

RewriteRule (.*) index.php/$1 [L] 
0

轉到.htaccess文件,並添加以下行...

RewriteEngine敘述上

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

重寫規則。 index.php