在根级别的。htaccess文件中,我尝试了这个301重定向代码,它有效:-
redirect 301 /en/about/product.html http://mydomain.com/shop?
然而,当我尝试复制句子时,对于其他页面,它总是以服务器错误500告终。
实际上,我应该如何在。htaccess中包含,比如10个重定向规则?
try this
RewriteEngine On
RewriteRule ^/en/about/product'.html?(.*)$ http://mydomain.com/shop/?$1 [R=301,L,S=1]
#other page
RewriteRule ^/en/about/product1'.html?(.*)$ http://mydomain.com/shop1/?$1 [R=301,L]
嗯,为了最好的可移植性,我建议您完全按照Apache mod_alias
文档中的指示键入指令,但除此之外它们是正确的。
Redirect 301 /the_old_page.htm http://example.com/the-new-page.htm
Redirect 301 /the_old_page2.htm http://example.com/the-new-page2.htm
Redirect 301 /the_old_page3.htm http://example.com/the-new-page3.htm
现在,你可能不需要50条规则。下面是一个示例,将示例url当作真正的url来处理:
RedirectMatch 301 ^/the_old_([^.]+)'.htm$ http://example.com/the-new-$1.htm
这将重定向所有的 url的形式"/the_old_<something>.htm"
到"/the-new-<something>.htm"
只有一个指令,而不是五十个。
如果你的旧url有这样的共性,你可以利用它来减少你需要编写、测试和维护的重定向指令的数量。