简体   繁体   English

301在同一个域/网站内重定向

[英]301 redirect within the same domain/website

The standard redirect 301 template for htaccess is usually: htaccess的标准重定向301模板通常为:

redirect 301 /folder_wrong/name.html http://website.com/folder-right/name.html 重定向301 /folder_wrong/name.html http://website.com/folder-right/name.html

With the http website included 包含http网站

I'm wondering if the below would work WITHOUT the http website and only having the directory, because all I'm doing is transferring from one directory to another: 我想知道下面的内容是否可以在没有http网站且仅具有目录的情况下工作,因为我所做的只是从一个目录转移到另一个目录:

redirect 301 /folder_wrong/name.html /folder-right/name.html 重定向301 /folder_wrong/name.html /folder-right/name.html

That is fine right? 没事吧?

No, you have to use the full URL. 不,您必须使用完整的URL。 See http://httpd.apache.org/docs/2.2/mod/mod_alias.html#redirect . 参见http://httpd.apache.org/docs/2.2/mod/mod_alias.html#redirect

As pointed out by Stijn in the comment below, you can specify the URL paths also starting from version 2.2.6. 正如Stijn在下面的注释中指出的,您也可以指定从版本2.2.6开始的URL路径。

You can use mod_rewrite if you need to overwrite only fragments of the URL. 如果只需要覆盖URL的片段,则可以使用mod_rewrite

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM