【问题标题】:Website article .htaccess 301 redirect网站文章 .htaccess 301 重定向
【发布时间】:2012-12-17 23:18:07
【问题描述】:

我在名为 patients 的文件夹中有一个站点,我的网址如下所示:

http://site.com/patients/职位名称

http://site.com/patients/articles/another-post-name

我想将它们全部重定向到一个干净的位置:

http://newsite.com/职位名称

http://newsite.com/another-post-name

换句话说,将有时出现的 /articles/ 和 301 丢到新站点。

关于如何使用 htaccess 执行此操作的任何帮助?

【问题讨论】:

    标签: apache .htaccess http-status-code-301


    【解决方案1】:

    http://site.com 服务器中编辑您的 .htaccess 并将其放入(必须是第一条规则):

    RewriteEngine On
    
    RewriteRule .* http://newsite.com/ [R=301]
    

    Redirect 301 / http://newsite.com/
    

    问候。

    【讨论】:

    • 如果传入的URL是http://site.com/patients/post-name,比如会被重定向到http://newsite.com/,那么URI的其余部分/post-name呢?
    猜你喜欢
    • 2017-09-21
    • 1970-01-01
    • 2012-05-15
    • 2021-04-07
    • 2018-08-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-02-04
    相关资源
    最近更新 更多