如何根据查询字符串重定向URL?

use*_*179 18 apache .htaccess mod-rewrite redirect

我成功地将Wordpress网站大规模迁移到了Drupal.不幸的是,在Wordpress中,内容网址类似于www.example.org/?p=123.我的域名仍然相同,但我想进行重定向,htaccess因为Drupal不允许URL为www.example.org/?p=123.换句话说,内容与Wordpress中的内容不同.例如,新的Drupal URL就像www.example.org/content/MyNewPage

我在我的.htaccess文件中尝试了这个,但它不起作用

Redirect 301 /\?p=375 http://www.example.org/content/MyNewPage
Run Code Online (Sandbox Code Playgroud)

所以我尝试了下面的内容,但它也不起作用.

Redirect 301 /\?p\=375 http://www.example.org/content/MyNewPage
Run Code Online (Sandbox Code Playgroud)

就像测试一样,我尝试了下面的工作.

Redirect 301 http://www.example.org http://www.google.com
Run Code Online (Sandbox Code Playgroud)

我确保我的重定向规则位于我的.htaccess列表的顶部,因此将首先对其进行评估.我该如何解决?

und*_*one 34

Redirect和RedirectMatch都不允许您为重定向源指定查询字符串. [资源]

您必须使用mod-rewrite基于查询字符串重定向:

RewriteCond %{QUERY_STRING}  ^p=375$
RewriteRule (.*)  http://www.example.org/content/MyNewPage?  [R=301,L]
Run Code Online (Sandbox Code Playgroud)