.htaccess - url重写mod_rewrite

标签 .htaccess mod-rewrite url-rewriting

我使用这个测试器进行 url mod_rewrite 测试: http://martinmelin.se/rewrite-rule-tester/

当我写这样的东西时:

RewriteRule ^x/([a-z]+)/([0-9]+)/$ x.php?x=$2 

即使我输入了网址:

x/p/6/

它被重命名为

x.php?x=p 

和。我想要的是

x.php?x=6

我是 mod 重写的新手,所以任何东西都会有用。

最佳答案

我自己并不是 mod_rewrite 方面的专家,但我认为该工具有问题。 例如,如果将 x.php?x=$2 更改为 x.php?$1=$2,则 $2 将被正确解析。 然后,CMIIW,但正则表达式看起来不错。测试正则表达式 herehere 。 您亲自尝试过 RewriteRule 吗?

关于.htaccess - url重写mod_rewrite,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7214396/

相关文章:

php - htaccess重写URL php参数

Wordpress 和 angular2 url 路由不起作用

apache - 干净的URL重定向循环

Javascript 重写 mousedown 上的所有外部链接?

regex - 重写 htaccess 中多次出现的术语

.htaccess - 从 http 重定向到 https 是否有加密

PHP 到 htaccess?

php - .htaccess 不适用于 php 包括

.htaccess - 使用 Apache 在 DDEV 中重定向 HTTP -> HTTPS

regex - 如何在 htaccess 重写规则正则表达式中添加点?