通过URL mod重写传递2个变量


Passing 2 variables with URL mod rewriting

这是我的重写代码:

RewriteEngine On
RewriteRule ^index$ index.php [L,QSA]
RewriteRule ^shopName/([^/]+)/(.*)?$ contactus.php?shopName=$1&shopId=$2 [L,QSA]

我的结果URL是:

http://noblenetwork.net/shopName/Eyepax/5

我需要将此URL自定义为:

http://noblenetwork.net/Eyepax

我不想在URL中显示id。请帮帮我。

.htaccess代码更改为

RewriteEngine On
RewriteRule ^index$ index.php [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/?(.*)$ contactus.php?shopName=$1&shopId=$2 [L,QSA]

如果商店id没有被传递,contactus.php将以&shopId=空白或null的形式接收它。所以,你可以同时使用

http://noblenetwork.net/Eyepax
http://noblenetwork.net/Eyepax/5