custom 301 redirects from old joomla (mambo) website to new drupal 7 website using .htaccess

做~自己de王妃 提交于 2019-12-25 02:55:30

问题


The past couple of hours I am trying to create custom redirects from an old mambo website to new drupal 7 website with the .htaccess file that exists in my drupal's root. What I want to do is...

301 Redirect

http://mysite.com/index.php?option=com_content&task=blogsection&id=11&Itemid=54

to

http://mysite.com/this-is-the-new-page

This is my .htaccess file...

RewriteEngine on

RewriteRule ^index.php?option=com_content&task=blogsection&id=11&Itemid=54$ http://mysite.com/this-is-the-new-page [R=301,L]

RewriteRule "(^|/)\." - [F]

RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [L,R=301]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^ index.php [L]

I am sure that it has something to do with this line...

RewriteRule ^ index.php [L]

But I don't get it! You see if I use this...

RewriteRule ^option=com_content&task=blogsection&id=11&Itemid=54$ http://mysite.com/this-is-the-new-page [R=301,L]

instead of this...

RewriteRule ^index.php?option=com_content&task=blogsection&id=11&Itemid=54$ http://mysite.com/this-is-the-new-page [R=301,L]

and test it with firefox and LiveHTTP Headers addon it works!

Any suggestions?!

Thanks!


回答1:


The query string is not part of the URL path pattern. If you want to base a rule on the query string, you must do so in a RewriteCond

RewriteEngine on
RewriteCond %{QUERY_STRING} option=com_content&task=blogsection&id=11&Itemid=54
RewriteRule ^index.php$ /this-is-the-new-page? [R,L]


来源:https://stackoverflow.com/questions/15534509/custom-301-redirects-from-old-joomla-mambo-website-to-new-drupal-7-website-usi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!