简体   繁体   English

Apache mod_rewrite:用查询字符串替换的路径

[英]Apache mod_rewrite: path replaced with query string

I have the following rule: 我有以下规则:

RewriteRule ^/([0-9]+)/([a-z0-9_-]*)\.([a-z]+)$ index.php?id=$2&type=$3&size=$1 [R=301,L]

The problem is that when I go to the URL /0/azerty.ext in a browser the URL is displayed as /index.php?id=azerty&type=ext&size=0 . 问题是,当我在浏览器中转到URL /0/azerty.ext ,URL显示为/index.php?id=azerty&type=ext&size=0 What I want is the redirection to be performed, with /0/azerty.ext as the visible URL. 我要执行的重定向是使用/0/azerty.ext作为可见URL。

I tried to remove the R=301 flag, but in that case the redirection is not performed. 我试图删除R=301标志,但是在那种情况下,不执行重定向。

What am I missing? 我想念什么?

找到了解决方案(在重定向的URL的开头添加斜杠),但不确定为什么...

RewriteRule ^/([0-9]+)/([a-z0-9_-]*)\.([a-z]+)$ /index.php?id=$2&type=$3&size=$1 [L]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM