Convert all get parameters in one
I have .htaccess file with the code:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) ?p=开发者_如何学Python$1 [L]
but I want it to convert not only URI string to a get parameter p but also all other get parameters to p, in other words:
domain.com/somewhere/somepage.html?foo=2 ----> domain.com/?p=urlencoded(somewhere/somepage.html?foo=2)How can I do that?Use following code in .htaccess file
Options +FollowSymlinks -MultiViews
RewriteEngine on
RewriteCond %{QUERY_STRING} !^p= [NC]
RewriteRule . /?p=%{REQUEST_URI}?%{QUERY_STRING} [L]
Since NE
flag is not provided here so mod_rewrite engine will encode your original URI before internally redirecting.
精彩评论