【问题标题】:Redirect 301 pages from old joomla to new site将 301 页面从旧 joomla 重定向到新站点
【发布时间】:2017-01-08 23:44:04
【问题描述】:

我在将页面从 Joomla 的旧站点重定向到不是 joomla 的新站点时遇到问题。这个我试过了

RewriteEngine On 
RewriteBase /

RewriteCond %{HTTP_HOST} ^oldsite.com$ [OR] 
RewriteCond %{HTTP_HOST} ^www.oldsite.com$ 
RewriteRule (.*)$ http://newsite.com/$1 [R=301,L]


RewriteRule ^/page http://newsite.com/pgs/page [R=301,L]
 ^ this redirect to newsite.com/page instead of newsite.com/pgs/page

RewriteRule ^/anotherpage http://www.newsite.com/cat/sub/sub-sub/productindex.php [R=301,L]
 ^ this redirect to newsite.com/anotherpage

如您所见,它仅重定向到根/页面...没有子页面等。有人可以帮忙吗?

如果我有 2 或 3 个不同的旧网址指向相同的新网址,该怎么办?喜欢这个:

RewriteRule ^/?oldpage http://www.newsite\.com/pgs/services/index.php [R=301,L,NC]
RewriteRule ^/?oldpage2 http://www.newsite\.com/pgs/services/index.php [R=301,L,NC]
RewriteRule ^/?oldpage3 http://www.newsite\.com/pgs/services/index.php [R=301,L,NC]

【问题讨论】:

    标签: apache .htaccess redirect mod-rewrite joomla


    【解决方案1】:

    通过重新排序规则来实现它:

    RewriteEngine On 
    
    RewriteRule ^/?anotherpage http://www.newsite.com/cat/sub/sub-sub/productindex.php [L,NC,R=301]
    
    RewriteRule ^/?page http://newsite.com/pgs/page [R=301,L,NC]
    
    RewriteCond %{HTTP_HOST} ^(?:www\.)?oldsite\.com$ [NC]
    RewriteRule ^ http://newsite.com%{REQUEST_URI} [R=301,L,NE]
    

    确保在测试这些规则之前清除浏览器缓存。

    【讨论】:

      猜你喜欢
      • 2016-06-07
      • 2019-07-03
      • 1970-01-01
      • 2012-10-11
      • 1970-01-01
      • 1970-01-01
      • 2010-11-28
      • 2013-10-25
      • 1970-01-01
      相关资源
      最近更新 更多