我正在使用
RedirectMatch 301 ^story.php?id=(.*) http://domain.com/p=$1
尝试和
301 redirect domain.com/story.php?id=xxxx to domain.com/p=xxxx
我错过了什么?
我使用的是centos 7,来自yum的最新httpd
http://domain.com/story.php?id=449
需要301重定向到
http://domain.com/?p=449
RewriteEngine On
RewriteCond %{QUERY_STRING} ^id=([^&]+) [NC]
RewriteRule ^story\.php$ /?p=%1? [L,NC,R=302]
RewriteBase /
Redirect 301 /forums http://domain.com
Options -Indexes
#RewriteEngine On
RewriteRule ^([a-z]{2}|zh-CN|zh-TW)/forums/(.*)$ /forums/$2 [R=301,L,QSA]
RewriteRule ^([a-z]{2}|zh-CN|zh-TW)/(.*)$ http://$1.domain.com/$2 [R=301,L,QSA]
RewriteRule ^(server-info|bb-server-status) - [L]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
答案 0 :(得分:0)
正如我上面评论的那样,您无法使用RedirectMatch
匹配查询字符串。请使用mod_rewrite
规则,如下所示:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^id=([^&]+) [NC]
RewriteRule ^story\.php$ /?p=%1 [L,NC,R=302]