Reputation: 121
Hello guys I want to pass everything written in get.php? url = parameter (including question mark and special characters). I have get.php file the file content:
$url = $_GET['url'];
print($url);
.htaccess file:
RewriteEngine On
RewriteBase /
RewriteRule ^get/(.*)/?$ /get.php?url=$1 [L]
I can get up to the question mark when I do it this way. Example: http://example.com/get/http://example.com?id=1&ad=mahmut
I am getting this result: http://example.com
How can i solve this problem? I tried many examples on the site but failed.
Upvotes: 0
Views: 293
Reputation: 785058
Trick is to not to use RewriteRule
since you will get only URI part before ?
.
You should be using a RewriteCond
with THE_REQUEST
variable for this:
Options -MultiViews
RewriteEngine On
RewriteCond %{QUERY_STRING} !(^|&)url= [NC]
RewriteCond %{THE_REQUEST} \s/+get/(\S*)\s [NC]
RewriteRule ^ get.php?url=%1 [L,QSA]
THE_REQUEST
variable represents original request received by Apache from your browser and it doesn't get overwritten after execution of other rewrite directives. Example value of this variable is GET /index.php?id=123 HTTP/1.1
Upvotes: 3