【发布时间】:2013-06-28 16:32:50
【问题描述】:
我有一个重定向器,它将url中/之后的所有内容作为参数提供给隐藏的index.php(然后使用js'window.location将用户重定向到另一个域,主机不支持外部重定向通过.htaccess),但我丢失了代码。每个文件(index.php、.htaccess)都在 /storage 文件夹中。
.htaccess 是这样的,但我想不通:
RewriteRule ^(.*) /?$1 [R,L]
这是一个无限循环的重定向。
输入http://storage.mysite.com/file.png 会打开http://storage.mysite.com/?file.png。
我试图避免在 .htaccess 中直接调用 index.php,因为它是这样重定向的:
<?php
echo "
<script>
window.location='http://otherdomain.com/12345678".$_SERVER['REQUEST_URI']."'
</script>
"; // note there's no slash after the number, the REQUEST_URI had it
?>
这样做的正确方法是什么?
【问题讨论】:
标签: php regex .htaccess mod-rewrite