2016-12-09 65 views
1

如何進行網址重寫,看起來像http://example.com/test.php的網頁會出現像http://example.com/index.php?/test而不是?Htaccess url rewrite add?/

這是我得到

RewriteEngine On 

RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^index.php?/([^/.]+)$ $1.php [L] 
+0

@anubhava是的,它是 –

+0

OK,你要重寫每一個'.php'文件或只是'test.php'? – anubhava

+0

@anubhava every .php :) –

回答

0

您可以使用此規則在根的.htaccess:

RewriteEngine On 

RewriteCond %{REQUEST_URI} !^/index\.php$ [NC] 
RewriteRule ^(.+)\.php$ index.php?/$1 [L,QSA,NC] 
+0

感謝您的回覆,但這似乎不起作用,不幸的是(它只顯示index.php和test.php顯示index.php) –

+0

根據您的問題'http://example.com/test.php'應該被轉發到'http://example.com/index.php?/ test',這就是這個規則的作用。 – anubhava

+1

對不起,我的工作:)謝謝 –