【发布时间】:2013-11-17 12:57:49
【问题描述】:
我创建了一个 .htaccess 文件,我尝试在其中重写某些 URL。我的目标是将 URL 作为参数传递给另一个脚本。它有点工作,但我最终得到的 URL 只在协议部分包含一个正斜杠(例如 http:/ 而不是 http://)
这是我的 .htaccess 文件
DirectoryIndex index.php
php_flag register_globals off
php_flag magic_quotes_gpc off
php_value display_errors 0
FileETag none
ServerSignature Off
Options All -Indexes
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^test/(.*)$ test.php?url=$1 [QSA,NC,NE,L]
</IfModule>
现在,当我请求以下内容时:http://example.org/test/http://myurl.com,php $_REQUEST 对象包含一个包含 http:/myurl.com
的 url 变量编辑当我请求时:http://example.org/test/http%3A%2F%2Fmyurl.com,URL 根本不会被重写(与重写正则表达式不匹配)
我似乎找不到这个问题的正确解决方案,转义字符似乎不是问题(因为那将是一个反斜杠)
【问题讨论】:
标签: php regex apache .htaccess mod-rewrite