Reputation: 550
I want to pass a url through a link
My htaccess code is :
RewriteRule ^info/(.*)$ folder1/page1.php?url=$1 [L]
But my result is :
$_GET['url'] = http:/stackoverflow.com (one slash is missing , http:/)
I need $_GET['url'] as http://stackoverflow.com
How is it possible using htaccess?
Can someone help me plz.....
Upvotes: 0
Views: 198
Reputation: 1553
If push comes to shove:
$_GET['url'] = str_replace('http:/', 'http://', $_GET['url']);
Upvotes: 0
Reputation: 785128
Using RewriteRule to match URI will not work because Apache will strip multiple slash into 1. Here is the code that makes it possible using %{THE_REQUEST}
:
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+info/([^\s\?]+) [NC]
RewriteRule ^ index.php?url=%1 [L,QSA]
Upvotes: 0
Reputation: 7804
its not possible, /
slash is url separetor. You must encode it before use as parameter. For example : site.com/info/http%3A%2F%2Fstackoverflow.com
$url = isset($GET['url']) ? urldecode($GET['url']) : 'default';
Or better dont use http://
. And site.com/info/stackoverflow.com
. In php:
$url = isset($GET['url']) ? 'http://'.$GET['url'] : 'default';
Upvotes: 1
Reputation: 20180
I think Xzibit has a valid point on this:
short story: use urlencode when you want to embed a url inside a link, i think it will fix your problem.
http://php.net/manual/en/function.urlencode.php
Upvotes: 4