使用.htaccess从url中删除两个GET参数

时间:2011-06-26 18:15:32

标签: .htaccess parameters get

我有一个看起来像这样的网址

http://example.com/index.php CON =东西&安培;满足= MEH

我要做的是摆脱con=met=,以便网址看起来像

http://example.com/index.php /东西/ MEH

这就是我到目前为止所做的事情

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ action=$1 [L,QSA]
RewriteRule ^(.*)$ page=$1 [L,QSA]

但没有任何变化,网址看起来仍然相同http://example.com/index.php ?con = something& met = meh

我做错了什么?

1 个答案:

答案 0 :(得分:3)

我确实喜欢这个:

RewriteEngine on
RewriteRule ^index.php/([^/]+)/?([^/]*) /index.php?con=$1&meh=$2 [NC]

请注意,如果你没有传递任何meh,它仍然有效。