我正在尝试重定向包含特定字符串的所有网址。网址看起来像这样
http://www.domain/com/modules.php?name=Kalender&op=list&d=8&m=6&y=2034
我必须重定向包含
的所有网址name=Kalender&
到
http://www.domain.com/kalender/
我在.htaccess中尝试了几条规则。他们都没有工作:
RewriteCond %{REQUEST_URI} name=Kalender&
RewriteRule .* kalender
RewriteRule ^(.)name=Kalender&(.)$ http://www.domain.com/kalender/ [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/name=Kalender&/i$ http://www.domain.com/kalender/ [NE,L]
RewriteCond %{REQUEST_URI} name=Kalender&
RewriteRule ^(.+)$ http://www.domain.com/kalender/ [L,R=301]
RewriteCond %{QUERY_STRING} ^name=Kalender&
RewriteRule ^name=Kalender& http://www.domain.com/kalender/ [R=301,L]
RewriteRule ^(.*)name=Kalender&(.*)$ http://www.domain.com/kalender/ [L,R=301]
RewriteCond %{REQUEST_URI} ^/modules.php?name=Kalender&$
RewriteRule ^(.*) http://www.domain.com/kalender [R=301,L]
这是WordPress .htaccess
<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)
您可以将此规则用作第一条规则:
RewriteCond %{QUERY_STRING} (^|&)name=Kalender(&|$) [NC]
RewriteRule ^ /kalender/? [L,R]