我想讓我的網址看起來像這樣:「http://www.example.com/start」, 而不是這樣:「http://www.example.com /index.php/start」。 與此代碼在我的.htaccess正常工作:.htaccess - Querystring without index.php
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1
在一個頁面上我有GET參數工作,URL應該是這樣的: 「http://www.example.com/藝術家/畢加索」, 而不是像這樣: ‘http://www.example.com/index.php/artists?artist=picasso’ 這也有可能用下面的代碼:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /index.php?/$1
RewriteRule ^artists/(.*)$ /index.php/artists?artist=$1 [L]
現在,這個解決方案的問題是,所有其他網址現在都必須以斜槓結尾。 所以它看起來是這樣的:「http://www.example.com/start/」,
而不是這樣的:「http://www.example.com/start」
感謝你的幫助 !
非常感謝! :)這工作。但是「RewriteCond%{REQUEST_URI}!artists /」是做什麼的? – Andri
@Andri它不是必須的,但它是爲了防止它匹配像'/ artists /'這樣的請求 –