问题描述
我成功地大规模迁移一个字preSS网站的Drupal。不幸的是在Word preSS,内容URL的是类似www.example.org/?p=123。我的域名仍然是相同的,但我想这样做,通过的htaccess
如Drupal将不允许使用网址的被www.example.org/?p=123~~V重定向。换句话说,内容不具有相同的URL,因为它在Word preSS做。例如,新的Drupal的URL会是这样 www.example.org/content/MyNewPage
I successfully mass migrated a Wordpress site to Drupal. Unfortunately in Wordpress, the content URL's were something like www.example.org/?p=123. My domain is still the same, but I want to do a redirect via htaccess
as Drupal will not allow URL's to be www.example.org/?p=123. In other words, the content does not have the same URL as it did in Wordpress. For example, the new Drupal URL would be something like www.example.org/content/MyNewPage
我在.htaccess文件中尝试这样做,这是行不通的。
I tried this in my .htaccess file and it does not work
Redirect 301 /\?p=375 http://www.example.org/content/MyNewPage
于是,我就在下面,但它也不行。
So I tried the below, but it does not work either.
Redirect 301 /\?p\=375 http://www.example.org/content/MyNewPage
正如一个测试,我尝试了下面,它的工作。
Just as a test, I tried the below and it worked.
Redirect 301 http://www.example.org http://www.google.com
我确信,我的重定向规则是在列表中我的.htaccess中的顶部,这样它会先被评估。我该如何解决这个问题?
I made sure that my Redirect rule is at the top of the list in my .htaccess so it will be evaluated first. How do I fix this?
推荐答案
既不重定向也不RedirectMatch允许您指定为重定向源的查询字符串。的
neither Redirect nor RedirectMatch allow you to specify a query string for the redirect source.[Source]
您必须使用国防部重写基于查询字符串重定向:
You have to use mod-rewrite for redirecting based on query string:
RewriteCond %{QUERY_STRING} ^p=375$
RewriteRule (.*) http://www.example.org/content/MyNewPage? [R=301,L]
这篇关于如何重定向基于查询字符串的URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!