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

2019-08-26 12:57发布

问题:

How would I do this URL change?

回答1:

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.



标签: url .htaccess