Wordpress HTACCESS 301 Redirect Querystring index.asp

时间:2016-10-11 14:59:44

标签: wordpress .htaccess redirect query-string

我有一个基本的WordPress HTACCESS。我想要完成的是301重定向:

/index.asp?id=herhaalrecept_aanvragen-5

https://www.example.nl/aanmelden-nieuwe-patienten/

我用QUERYSTRING尝试了很多选项,但没有运气。我从下面的例子中删除了它,因为我认为它甚至不是很接近。

有人有想法吗?

提前Tnx

我的HTACCESS示例现在如下:

# 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]

Redirect 301 /index.asp?id=herhaalrecept_aanvragen-5 https://www.example.nl/aanmelden-nieuwe-patienten/

</IfModule>
# END WordPress

1 个答案:

答案 0 :(得分:1)

RedirectRewriteRule与查询字符串不匹配。您需要RewriteCond,因此您必须在其他WP规则之前保留该规则。

RewriteEngine On
RewriteBase /

RewriteCond %{QUERY_STRING} (?:^|&)id=herhaalrecept_aanvragen-5(&|$)  [NC]
RewriteRule ^index\.asp$ https://www.example.nl/aanmelden-nieuwe-patienten/? [L,R=301,NC]

RewriteRule ^index\.php$ - [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php? [L]