htaccess With a different amount of variables

2019-07-25 00:03发布

I have a website that on one specific page it requires an extra variable.

At the moment, the htaccess I am using is:

RewriteEngine On
RewriteRule ^([^/]*)/$ /index.php?page=$1 [L]

Which works fine with one variable.

How would I get it to work with : http://tessite.com/index.php?page=test&id=1

So it looked like: http://tessite.com/test/1

Thanks for any help or replies.

2条回答
甜甜的少女心
2楼-- · 2019-07-25 00:30
RewriteEngine On
RewriteRule ^(.*)/(.*)/$ /index.php?page=$1&id=$2 [L]
RewriteRule ^(.*)/$ /index.php?page=$1 [L]

Just add $2!

Also, [^/] isn't required, you can simply use ..

查看更多
爷、活的狠高调
3楼-- · 2019-07-25 00:37

It can be coded like this:

RewriteRule ^([^/]*)/([^/]*)/$ index.php?page=$1&id=$2 [L]
查看更多
登录 后发表回答