在mod_rewrite的preserving双斜杠 [英] Preserving double slashes in mod_rewrite

查看:88
本文介绍了在mod_rewrite的preserving双斜杠的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我到处去寻找这个答案,和它给了我404错误已张贴的答案不适合我的具体情况,我不知道为什么。

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, and I'm not sure why.

我想改写这个: /c.php?url=http://www.example.com

进入这个: /c/http://www.example.com

现在我有这个在我的mod_rewrite的:

Right now I have this in my mod_rewrite:

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

但是,当重写,我试图发送到PHP脚本的URL,它写道: HTTP:/example.com ,一个斜线,而不是双斜杠。

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.

我见过很多事情上发布有关此涉及THE_REQUEST规则,但是当我尝试将其应用到我的htaccess文件,他们失败了。我不知道什么是错的,任何帮助将是非常美联社preciated。

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.

推荐答案

阿帕奇删除路径内的多个斜线。正如你已经提到的,你可以通过检查请求线在解决这个的 THE_REQUEST 的:

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

这篇关于在mod_rewrite的preserving双斜杠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆