RewriteRule接受2个参数

时间:2011-09-23 22:44:23

标签: .htaccess mod-rewrite

mydomain.com/MyFolder/parameter-1

我有这个htaccess RewriteRule -

RewriteRule ^([a-z0-9\-]+)/?$ index.php?c=$1 [NC,L]

.htaccess文件位于MyFolder内,这只接受一个参数。

如何使RewriteRule接受2个参数

mydomain.com/MyFolder/parameter-1/parameter-2

由于

1 个答案:

答案 0 :(得分:7)

使用它:

RewriteEngine On

# mydomain.com/MyFolder/parameter-1
RewriteRule ^([a-z0-9\-]+)/?$ index.php?c=$1 [NC,L]

# mydomain.com/MyFolder/parameter-1/parameter-2
RewriteRule ^([a-z0-9\-]+)/([a-z0-9\-]+)/?$ index.php?c=$1&d=$2 [NC,L]