.htaccess rewriteEngine with multiple get variables



有没有办法更改具有多个变量的网址,例如这个网址:

index.php?p=place&c=Munich

自:

/place/munich

使用 .htaccess?

您可以在根 .htaccess 中使用此规则:

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

根据这两个参数包含的字符,下面是一个仅用于字母 (a-zA-Z) 的参数:

RewriteRule ^([a-zA-Z]+)/([a-zA-Z]+)$ index.php?p=$1&c=$2

最新更新