我有一個關於mod_rewrite的問題 - 我有以下網址:PHP - mod_rewrite的與參數
http://website.com/profile/index.php?a=profile&u=username
我試圖重寫到:
http://website.com/profile/user/username
我已經在我的.htaccess
以下文件:
RewriteEngine on
RewriteRule ^/profile/user/([^/]*)$ /profile/index.php&a=profile&u=$1 [L]
雖然當去重寫的URL,我沒有看到該頁面。我只看到默認的index.php頁面。我試圖通過印刷得到paramters:print_r($_GET);
這給了我如下:
Array ([a] => u [q] => /username)
現在我的問題是 - 我怎麼能改寫第一URL到第二?顯然,a
是空的,而u
還含有/
你試試:'^重寫規則/型材/用戶/([^ /] *)$ /index.php&a=$1&u=$2 [L]' – 2015-04-06 08:08:26
然後@Testing了'了'參數變爲' user' - 應該是'profile'以便index.php頁面獲得正確的文件。 – oliverbj 2015-04-06 08:10:03
看我上面的編輯.. @oliverbj – 2015-04-06 08:14:38