2013-03-20 107 views
0

過去幾個小時我試圖創建自定義重定向從舊mambo網站到存在.htaccess文件的新drupal 7網站在我的drupal的根。 我想要做的是什麼...自定義301使用.htaccess從舊joomla(mambo)網站重定向到新drupal 7網站

301重定向

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

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

這是我的.htaccess文件...

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] 

我相信它與這條線有關...

RewriteRule^index.php [L] 

但我不明白! 你看,如果我用這個...

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頭測試插件它的作品!

有什麼建議?

謝謝!

回答

1

查詢字符串不是URL path pattern的一部分。如果您想在查詢字符串上設置規則,則必須在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] 
+0

謝謝您的回覆!它執行重定向,但在最後添加了QUERY_STRING。所以現在我有http://mysite.com/this-is-the-new-page?option=com_content&task=blogsection&id=11&Itemid=54 :( – kanenas 2013-03-20 21:39:45

+0

@ kanenas.net對不起,我總是忘記添加一個問號'? '在替代結束時,修正。 – 2013-03-20 21:45:06