页面名称前的.htaccess隐藏参数

时间:2012-06-13 04:48:27

标签: php apache .htaccess mod-rewrite

我正在尝试重写网址:

http://www.domain.com/contact?language=en
http://www.domain.com/?language=en

为:

http://www.domain.com/en/contact
http://www.domain.com/en/

使用:

RewriteRule ^([^/]*)/([^/]+)/?$ $2/index.php?language=$1 [QSA,L]

我不确定为什么这不起作用!?

修改

我将规则更改为:

RewriteRule ^([^/]*)/([^/]*)/?$ $2/?language=$1 [QSA,L]

这不会给URL带来错误,就像它上面的旧规则一样。但是,它没有转到指定的目录

http://www.domain.com/en/contact <- stays at the / (root)

1 个答案:

答案 0 :(得分:1)

RewriteEngine On
RewriteBase /
RewriteRule ^(en|fr|de|nl)/(.*)$ /$2?language=$1 [QSA,L]