如何進行網址重寫,看起來像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]
如何進行網址重寫,看起來像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]
您可以使用此規則在根的.htaccess:
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/index\.php$ [NC]
RewriteRule ^(.+)\.php$ index.php?/$1 [L,QSA,NC]
感謝您的回覆,但這似乎不起作用,不幸的是(它只顯示index.php和test.php顯示index.php) –
根據您的問題'http://example.com/test.php'應該被轉發到'http://example.com/index.php?/ test',這就是這個規則的作用。 – anubhava
對不起,我的工作:)謝謝 –
@anubhava是的,它是 –
OK,你要重寫每一個'.php'文件或只是'test.php'? – anubhava
@anubhava every .php :) –