开发者

Preserving double slashes in mod_rewrite

I have searched everywhere for this answer, and the answers that have been posted do not fit my specific situation as it gives me 404 errors, 开发者_JS百科and I'm not sure why.

I am trying to rewrite this: /c.php?url=http://www.example.com

Into this: /c/http://www.example.com

Right now I have this in my mod_rewrite:

RewriteEngine on
RewriteRule ^c/(.*)(/)?$ /c.php?url=$1

But when it rewrites the url that I am trying to send into the PHP script, it writes "http:/example.com", with one slash instead of the double slash.

I've seen a lot of things posted about this involving the THE_REQUEST rule, but when I try to apply them to my htaccess file, they fail. I am not sure what is wrong, any help would be much appreciated.


Apache removes multiple slashes inside the path. And as you’re already mentioned, you can solve this by inspecting the request line in THE_REQUEST:

RewriteCond %{THE_REQUEST} ^[A-Z]+\ /c/([^?\ ]+)/?
RewriteRule ^c/ /c.php?url=%1
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜