【问题标题】:htaccess redirect only subdirectory requests (not requests for TLD)htaccess 仅重定向子目录请求(不是 TLD 请求)
【发布时间】:2011-03-10 20:42:38
【问题描述】:

我将博客从 example.com 移至 example.com/blog。我现在在 example.com 上有一个启动页面。我希望像 example.com/2011/example-post 这样的旧博客帖子请求重定向到 example.com/blog/2011/example-post;但允许对 example.com 的请求没有重定向。

【问题讨论】:

    标签: .htaccess redirect indexing subdirectory permanent


    【解决方案1】:

    试试这个:

    RewriteEngine On
    RewriteRule ^([0-9]{4}/.+)$ /blog/$1 [R=301,NC]
    

    这将重定向所有具有 4 位数字(年份)和斜线后的内容,因此您在 example.com 中的所有内容都将像普通页面 example.com/about.html 一样工作

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-08-08
      • 1970-01-01
      • 1970-01-01
      • 2012-06-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多