2017-03-06 62 views
1

這裏有一個.htaccess文件,其中只removes.php但我想也實現?ID =也將被刪除 (例如)本地主機/ new1v2/alumni.php?ID = 43將顯示爲localhost/new1v2 /校友刪除?ID的.htaccess

這裏是我的.htaccess

RewriteEngine On 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^([^\.]+)$ $1.php [NC,L] 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^alumni alumni.php?id=43 

回答

0

在你的htaccess的頂部,補充一點:

RewriteEngine on 
RewriteCond %{QUERY_STRING} ^id=.+$ 
RewriteRule (.+)\.php$ /$1? [L,R] 

這將刪除現有的queryString ?id = nm並將您的php網址從/foobar.php?id=nm重定向到/foobar

+0

它刪除ID?=但它也刪除該文件夾?爲什麼?從localhost/new1v2/view_events?id = 2到localhost/view_events – sauce