I'm making a redirect script for my site, I use htaccess to rewrite the URL so it looks nicer.

eg. http://localhost/r/http://google.com is the URL, but when I printing the value it shows up like this http:/google.com.
One / is missing, how can I fix that?

Edit:
Rewrite rule:
RewriteRule ^r/(.*)/$ /system/offsite/redirect/index.php?url=$1 [L]

Thanks for any help :)

Comments

Maybe you should show us your rewrite rules.

Written by ceejayoz

urlencode() / urldecode() may fix that problem

Written by Lawrence Cherone

^r/(.*)/$ expects a / at the end of the address tobe redirected, like localhost/r/http://google.com/ so removing it may fix your issue

Written by Lawrence Cherone

Accepted Answer

This behavior is due to Apache that removes empty path segments before mapping it. But you can access the original requested URI path via THE_REQUEST:

RewriteCond %{THE_REQUEST} ^GET\ /r/([^\ ]+)
RewriteRule ^r/ /system/offsite/redirect/index.php?url=%1 [L]
Written by Gumbo
This page was build to provide you fast access to the question and the direct accepted answer.
The content is written by members of the stackoverflow.com community.
It is licensed under cc-wiki