PHP & .htaccess - turn example.com/index.php?a=6&b

2019-08-26 12:57发布

How would I do this URL change?

标签: url .htaccess
1条回答
Luminary・发光体
2楼-- · 2019-08-26 13:23

Try this mod_rewrite rule:

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

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

And if you rather want the other way round:

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

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

查看更多
登录 后发表回答