unable to escape "?" in the url rewriting in htaccess

117 views Asked by At

I have URL as: spa-shop/admin/index?docid=abc ,For this URL i am using htacces Rewrite Rule. The rule is as follow:

RewriteRule ^((?i)spa-shop)/(admin)/([a-zA-Z\?]*)$             spavendor/index.php?url=spaAdmin/$3 [L]

In this the output which i am expecting is : spashop/index.php?url=spaAdmin/index?docid=abc , but I am getting the URl as: spashop/index.php?url=spaAdminShop/index. Please let me know what is the problem though i am escaping the ? in the rewrite rule. But it seems not being escaped.

2

There are 2 answers

0
anubhava On BEST ANSWER

You can replace your rule by this rule:

RewriteRule ^(spashop)/admin/([a-zA-Z]+)/?$ $1/index.php?url=spaAdminShop/$2\?%{QUERY_STRING} [L,NC]
2
Identity1 On

You need to use

urlencode($someURl)

This will encode ? to %3F