我正在嘗試制定 .htaccess 重定向規則以實作以下目標
https://www.example.net/index.php?a=in&u=testUser&api_key=4r98f4r98f&ip_address=127.0.0.1
到
https://www.example.net/api.php?ip=127.0.0.1&username=testUser
但我不能讓它作業,有什么提示嗎?
RewriteEngine on
RewriteCond %{QUERY_STRING} ^a=([^&] )&u=([^&] )&api_key=([^&] )&api_key=([^&] )&ip_address=([^&] )$ [NC]
RewriteRule ^index\.php$ https://www.example.net/api.php?ip=%5&username=%2? [NC,L,R]
uj5u.com熱心網友回復:
您api_key的條件中有兩次引數,而且不要捕獲不需要在目標中重用的值。最后還有一個額外的放錯地方?。
有這樣的規則:
RewriteCond %{QUERY_STRING} ^a=[^&]*&u=([^&] )&api_key=[^&]*&ip_address=([^&] )$ [NC]
RewriteRule ^index\.php$ /api.php?ip=%2&username=%1 [NC,L,NE,R=302]
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/378450.html
