【问题标题】:How to change webroot and make ftproot invisible to browsers?如何更改 webroot 并使 ftproot 对浏览器不可见?
【发布时间】:2017-06-13 10:37:57
【问题描述】:

我试图通过将 webroot 指向我的 ftproot 中的特定子文件夹来保护 ftp 根

-root (sub.mydomain.com)
    -index.html (for testing, this should not show)
    -conf
    -src
    -public
        -index.html (this should always show)

我尝试在 fptroot 中放置一个 .htaccess 文件,如下所示:

RewriteEngine On
RewriteRule ^$ /public [L]

我也尝试了几个不同的谷歌搜索,但我最终还是可以访问 root/index.html。

下面的这个实际上是根据需要重定向的,但是 /public_html/ 显示在浏览器中,这显然不是我想要的。

RewriteEngine On
 RedirectMatch ^/$ /public/

下面这个做同样的事情

RewriteEngine On
RewriteCond %{REQUEST_URI} ^/$
RewriteRule (.*) http://sub.mydomain.com/public [R=301,L]

我希望除了 root/public 之外的所有内容都对浏览者完全不可见。许多虚拟主机默认为您完成此设置,但我在这个项目中没有那么奢侈。

【问题讨论】:

    标签: .htaccess ftp root


    【解决方案1】:

    这将为您完成,将其放入您的根 .htaccess 文件中:

    RewriteEngine on
    RewriteCond %{REQUEST_URI} !^/public/
    RewriteRule ^(.*)$ public/$1
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-07-08
      • 1970-01-01
      • 2021-04-09
      • 2014-09-16
      • 1970-01-01
      • 1970-01-01
      • 2023-03-27
      相关资源
      最近更新 更多