-1
我正在使用PHP 5.3.5的Wamp和htaccess
已啓用。刪除'index.php?'使用.htaccess
我面臨的問題是我需要像這樣的東西http://localhost/abc/aboutus
。
現在實際的URL是這樣的http://localhost/abc/index.php?aboutus
我嘗試下面的代碼:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
並嘗試使用它像http://localhost/abc/aboutus
,但它並不適用於工作。但是當我嘗試像http://localhost/abc/?aboutus
。
它工作正常,但我實際上想從URL中刪除?
。誰能告訴我我錯在哪裏?
我認爲你需要一個斜槓的模式'^/ABC的前/(.*)$'並刪除斜線查詢字符串'... $ 1'? –
@OlafDietsche如果規則在服務器或vhost配置中,則只需在模式前面使用斜線。在發送到htaccess文件中的規則之前,斜槓始終從URI中剝離。 –
謝謝您的解釋。我不知道這一點。 –