最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

htaccess - how to redirect 301 my old search query string to wordpress search query string?

programmeradmin5浏览0评论

How to redirect 301:

/cgi-bin/mt/mt-search.cgi?search=WORDS

to

/?s=WORDS

in .htaccess file?

How to redirect 301:

/cgi-bin/mt/mt-search.cgi?search=WORDS

to

https://example/?s=WORDS

in .htaccess file?

Share Improve this question edited Dec 24, 2019 at 22:53 MrWhite 3,8911 gold badge20 silver badges23 bronze badges asked Dec 24, 2019 at 14:52 raminramin 1134 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

Try something like the following at the top of your root .htaccess file (before the WordPress block):

RewriteCond %{QUERY_STRING} ^search=([^&]*)
RewriteRule ^cgi-bin/mt/mt-search\.cgi$ /?s=%1 [R=301,L]

%1 in the RewriteRule substitution is a backreference to the captured group in the preceding CondPattern (ie. the value of the search URL parameter - "WORDS").

Clear your browser cache before testing.

It is preferable to first test with a 302 (temporary) redirect to avoid caching issues.

Reference:
https://httpd.apache/docs/current/mod/mod_rewrite.html

发布评论

评论列表(0)

  1. 暂无评论