2012-03-05 122 views
2

我需要使用$ _GET在PHP virable,我的.htaccess重寫URL:htaccess的如何轉換特殊字符

本地主機/光韻/ GM /到localhost /光韻/ index.php的代碼=克

這是我的.htaccess的代碼:

RewriteEngine On 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_URI} !(.*)/$ 
RewriteRule ^(.*)$ index.php?code=$1 

,但是當我鍵入本地主機/光韻/ p & p /我只獲得使用$ _GET第一p!

我想才能計算P使用$ _GET

& p

誰能幫我在這?

回答

0

改變你的重寫規則到:

RewriteRule ^(.*)$ index.php?code=$1 [L,QSA] 
+0

我以前試過,但它沒有工作,而是把我帶到一個不正確的URL(禁止):HTTP://本地主機/ d:/的appserv/WWW /arpege/index.php?code=p&p。無論如何,這不會將'&'轉換爲%26,對嗎? – LRA 2012-03-05 22:50:42

+1

您可以嘗試'RewriteRule ^(。*)$ /index.php?code=$1 [L,QSA,NE]'此外,當您手動鍵入URL時,瀏覽器本身會發生'&'到%26轉換。如果它是代碼的一部分,那麼你可以使用像'localhost/arpege/p%26p /'編程的URL。 – anubhava 2012-03-06 04:47:29