mod_rewrite在重写时不会更改链接

时间:2012-12-06 08:29:43

标签: .htaccess mod-rewrite url-rewriting

我的.htaccess

有以下内容
RewriteEngine on
RewriteRule ^page/([^/\.]+)/?$ index.php?page=$1 [L]

当我致电www.mydomain.com/page/myvalue时,我得到了正确的结果。为了达到这个目的,我需要更改我网站的所有链接吗?

有没有办法完成相反的工作,即当我调用index.php?page = $ 1将我重定向到www.mydomain.com/page/myvalue?

1 个答案:

答案 0 :(得分:1)

将此规则添加到.htaccess:

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+index\.php\?page=([^\s&]+) [NC]
RewriteRule ^ page/%1? [R=301,L]