我正在为我的网站制作一个重定向脚本,我使用 htaccess 重写 URL,使其看起来更好。
例如。http://localhost/r/http://google.com
是 URL,但是当我打印该值时,它显示如下 http:/google.com
.缺少一个
/
,我该如何修复?
编辑:
重写规则:
RewriteRule ^r/(.*)/$/system/offsite/redirect/index.php?url=$1 [L]
感谢您的帮助:)
最佳答案
此行为是由于 Apache 在映射之前删除了空路径段。但您可以通过 THE_REQUEST 访问原始请求的 URI 路径:
RewriteCond %{THE_REQUEST} ^GET\ /r/([^\ ]+)
RewriteRule ^r/ /system/offsite/redirect/index.php?url=%1 [L]
关于php - $_GET URL 来自 ?url=http ://google. com,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6003028/