I have a page that asks a user to confirm if he wants to continue or cancel and I use a rewrite rule for it:
RewriteRule ^click/(.+)$ aclick.php?url=$1 [B]
The problem arises when the URL has a question mark. For example:
http://example.com/click/yahoo.com/mobile/?s=ladygaga
My goal is that this URL be re-written as:
http://example.com/aclick.php?url=yahoo.com/mobile/%3fs=ladygaga
So that the continue button will proceed to: ‘http://yahoo.com/mobile/?s=ladygaga’
However, the continue button is just linked to ‘http://yahoo.com/mobile/’.
Does anyone have an idea to fix this?
Use
%{QUERY_STRING}as follows. You have to referREDIRECT_QUERY_STRINGinstead ofQUERY_STRING.Bflag will escape the string excessively. If you accesshttp://example.com/click/yahoo.com/mobile/?s=ladygaga, the query string will beurl=yahoo%2ecom%2fmobile%2f?s=ladygaga. (It does not cause bad influence.)In case that URL have no query string, redundant “?” is added to the end of query string. To prevent this, use
RewriteCond:You can simply written as follows:
Program aclick.php can refer environment variables
REQUEST_URI,REDIRECT_URL,QUERY_STRINGetc.