本文介绍了PHP &.htaccess - 将 example.com/index.php?a=6&b=3 变成 example.com/6/3?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将如何更改此 URL?

How would I do this URL change?

推荐答案

试试这个 mod_rewrite 规则:

RewriteEngine on
RewriteCond %{QUERY_STRING} ^a=(\d+)&b=(\d+)$
RewriteRule ^index\.php$ %1/%2

这会在内部将 /index.php?a=6&b=3 的请求重写为 /6/3.

This will rewrite a request of /index.php?a=6&b=3 internally to /6/3.

如果你想反过来:

RewriteEngine on
RewriteRule ^(\d+)/(\d+)$ index.php?a=$1&b=$2

这会在内部将 /6/3 的请求重写为 /index.php?a=6&b=3.

This will rewrite a request of /6/3 internally to /index.php?a=6&b=3.

这篇关于PHP &.htaccess - 将 example.com/index.php?a=6&b=3 变成 example.com/6/3?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 17:14
查看更多