1
我想一些幫助重寫一個醜陋的URL(http://example.com/image.php?id=1&name=Dog),以使用正則表達式一個漂亮的URL(http://example.com/1/Dog)。重寫規則 - 從醜陋的URL漂亮與不變量解析正確
有很多關於此相反的版本問題,一個我需要的一些其他版本。儘管如此,他們不工作。
RewriteRule ^image.php\?id=(.*)&name=(.*)$ http://example.com/$1/$2? [R=301,L]
這是我想出的正則表達式。測試它Regex101似乎要被罰款https://regex101.com/r/uUlccx/2
它應該是這一個相反(?):
RewriteRule ^([^/]*)/([^/]*)$ /image.php?id=$1&name=$2 [L]
但現在看來似乎並非如此。任何人都知道RewriteRule應該如何?
編輯:http://htaccess.mwl.be?share=47b41b23-1752-5a26-8432-196c95d1d669 htaccess的測試
編輯2:我有一點點進一步,但似乎仍然沒有被完全工作。第二個變量不採取在來重寫:
RewriteCond %{QUERY_STRING} ^(.*&)?id=(.*)&name=(.*)$
RewriteRule ^image\.php$ http://example.com/%1/%2/? [R=301,L]