我有问题,将旧网站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
正如您所看到的那样,它只能重定向到root / page ...没有获取子页面等。任何人都可以帮忙吗?
如果我有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]
答案 0 :(得分:3)
通过重新排序规则来实现这一目标:
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]
确保在测试这些规则之前清除浏览器缓存。