Ryan Doherty
Ryan Doherty

Reputation: 38740

Rewrite rule stripping characters

I have this rewrite rule in my .htaccess file, but in PHP when I get the url ($_GET['url']) it strips out one of the slashes from http://

RewriteRule ^details/([0-9]+)/(.*)$ details/index.php?urlid=$1&url=$2 [L,QSA]

If the url is http://foo.com/details/12345/http://www.bar.com/dsfkjds, PHP sees http:/www.bar.com/dsfkjds

I'm not sure if this is a PHP, regex or apache problem. Any help appreciated, thanks!

Upvotes: 0

Views: 160

Answers (1)

mario
mario

Reputation: 145482

This is Apache normalizing the path segments. It's too late for the RewriteRule to detect or change it.

You can however see the original request URL in $_SERVER["REQUEST_URI"] and apply your regex again to see the full parameter.

preg_match("#^/+details/+([0-9]+)/+(.*)$#", $_SERVER["REQUEST_URI"], $m)
and $url = $m[2];

Upvotes: 2

Related Questions