使用.htaccess重写wordpress预览URL

时间:2011-11-12 13:47:31

标签: apache wordpress .htaccess rewrite

我正在尝试进行以下重写:

mydomain.com/?p=706&preview=true to
mydomain.com/index.php?p=706&preview=true

使用RewriteRule ^/?p=([0-9]+)&preview=true$ /index\.php [QSA,L]

然而,它没有重定向,我做错了什么?

2 个答案:

答案 0 :(得分:0)

将其替换为:

RewriteCond %{QUERY_STRING} ^p=([0-9]+)&preview=true
RewriteRule . /index.php [QSA,L]

QSA表示“将查询字符串从请求附加到替换的URL”

答案 1 :(得分:-1)

删除/

RewriteRule ^/?p=([0-9]+)&preview=true$ /index\.php [QSA,L]
            ^^^

所以...

RewriteRule ^?p=([0-9]+)&preview=true$ /index\.php [QSA,L]