重寫動態URL後無法重定向。.htaccess動態URL重定向
動態URL:http://localhost/amploutargetsharing/campaigninfo.php?unique_hash=f5f386e
重定向後,我想要的網址看起來像下面。
所需的URL:http://localhost/amploutargetsharing/f5f386e
正如我google一下,寫下面的代碼。
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/amploutargetsharing/campaigninfo\.php$
RewriteCond %{QUERY_STRING} ^unique_hash=([a-z0-9]*)$
RewriteRule ^(.*)$ http://localhost/amploutargetsharing/%1 [R,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ campaigninfo.php?unique_hash=$1 [L,QSA]
而上面的代碼給了我下面的結果。
HTTP //本地主機/ amploutargetsharing/f5f386e?unique_hash = f5f386e
但我想要的網址看起來像上述所需的URL。
可能重複http://stackoverflow.com/questions/30591437/ htaccess-rewrite-to-remove-query-string) – CBroe
是的,這是一個真正的目錄Anubhava爵士 –