【问题标题】:.htaccess rewrite to redirect only root access to a specific subdirectory, while other folders are kept.htaccess 重写以仅将 root 访问重定向到特定子目录,而保留其他文件夹
【发布时间】:2014-10-25 23:38:04
【问题描述】:

有没有办法我可以进行 .htaccess 重写以仅将 root 访问重定向到特定子目录,而保留其他文件夹。

我得到的是

www.testing.com/a
www.testing.com/b
www.testing.com/c

我想保留

www.testing.com/a
www.testing.com/b

并将任何访问重定向到 www.testing.comwww.testing.com/c 是透明的,所以用户仍然可以在 URL 栏上看到 www.testing.com

我试过RedirectMatch,但它只是重定向所有内容。

【问题讨论】:

    标签: .htaccess mod-rewrite redirect url-redirection


    【解决方案1】:

    您可以在DOCUMENT_ROOT/.htaccess 文件中使用此代码:

    RewriteEngine On
    
    RewriteRule ^/?$ /c/ [L]
    

    这将静默重写www.testing.com/www.testing.com/c/

    【讨论】:

      猜你喜欢
      • 2016-06-27
      • 1970-01-01
      • 1970-01-01
      • 2011-01-14
      • 2018-05-28
      • 2020-01-08
      • 1970-01-01
      • 2017-01-29
      • 2021-09-03
      相关资源
      最近更新 更多