尝试创建小网址,获得重定向循环
我正在尝试创建这样的小网址:
site.com/abc123
转到:
site.com/index.php?token=abc123
但无论我尝试什么,我都会不断收到重定向循环,或者它尝试重定向到 index.php?token=index.php ..
当前 .htaccess 是:
Options +FollowSymLinks
Options -MultiViews
RewriteEngine On
RewriteRule ^([^/]*)$ /index.php?token=$1 [L]
I'm trying to create tiny urls like this:
site.com/abc123
goes to:
site.com/index.php?token=abc123
but I keep getting redirect loops no matter what I try, or it tries to redirect to index.php?token=index.php..
Current .htaccess is:
Options +FollowSymLinks
Options -MultiViews
RewriteEngine On
RewriteRule ^([^/]*)$ /index.php?token=$1 [L]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这就是我所做的(我正在重定向字母数字代码,例如 http://myurl.com/b32ad ) :
Here's what I've done (I'm redirecting alphanumeric codes like http://myurl.com/b32ad ):
我昨天回答了类似的问题: htaccess:重定向动态 URL - 仅显示静态 URL - 双内容
这应该可以做到:
I have answered a similar question yesterday: htaccess: Redirect a Dynamic URL - Show only Static URL - Double Content
This should do it:
这很奇怪,因为您已将
[L]
选项附加到该规则。是否可能存在由其他原因引起的外部重定向?无论如何,您可以将规则限制为对不存在文件(也可能是目录)的请求。
请参阅http://httpd.apache.org/docs/2.2/mod /mod_rewrite.html#rewritecond
That's strange since you have the
[L]
option attached to that rule. Could there be an external redirect caused by something else?Anyway, you could limit the rule to requests for non-existing files (maybe directories, too).
see http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewritecond