自定义 301 使用 .htaccess 从旧的 joomla (mambo) 网站重定向到新的 drupal 7 网站 [英] custom 301 redirects from old joomla (mambo) website to new drupal 7 website using .htaccess

查看:26
本文介绍了自定义 301 使用 .htaccess 从旧的 joomla (mambo) 网站重定向到新的 drupal 7 网站的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

过去几个小时,我正在尝试使用我的 drupal 根目录中存在的 .htaccess 文件创建从旧 mambo 网站到新 drupal 7 网站的自定义重定向.我想做的是……

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 重定向

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

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

这是我的 .htaccess 文件...

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]

而不是这个...

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

并使用 firefox 和 LiveHTTP Headers 插件对其进行测试!

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

有什么建议吗?!

谢谢!

推荐答案

查询字符串不属于 URL 路径模式.如果要基于查询字符串建立规则,则必须在 RewriteCond

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]

这篇关于自定义 301 使用 .htaccess 从旧的 joomla (mambo) 网站重定向到新的 drupal 7 网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆