首页 文章

htaccess从url中删除目录

提问于
浏览
1

我的主要问题是我有很多目录要隐藏在访问我网站的客户身上 .

我的基本网址:http://example.com/qf/development/templates/webApp/

我想为访问客户隐藏的是这些目录“/ qf / development / templates /”

我已尝试在Web根目录中的http://example.com/.htaccess目录中的.htaccess文件中使用以下内容

这是我的.htaccess文件中的内容,但无法正常工作..

选项FollowSymLinks -MultiViews

RewriteEngine On

RewriteBase /

RewriteRule ^ qf $ qf / development / templates / webApp / index.php

2 回答

  • 0

    你可以尝试这个规则

    RewriteEngine on 
     RewriteBase / 
     RewriteRule ^qf/?$ qf/development/templates/webApp/index.php [L,NC]
    

    这将重定向www.example.com/qf to www.example.com/qf/development/templets/webApp/index.php

    Or

    将以下行添加到.htaccess文件中

    IndexIgnore *dir
    

    这告诉Apache Web服务器列出除IndexIgnore中的文件之外的所有文件

    example 1 如果要隐藏名为 foo 的目录,请将以下行添加到.htaccess文件中

    IndexIgnore *foo
    

    example 2 如果要隐藏以 .bar 结尾的文件,请将以下行添加到.htaccess文件中

    IndexIgnore *.bar
    

    如果要禁用列表中的所有文件和目录,请将此行添加到.htaccess

    IndexIgnore *
    

    通配符'*'表示它不会显示任何文件

  • 0

    我的解决方案

    在你当前的 .htaccess

    RewriteEngine off
    Options -Indexes
    

    这将阻止从您的根目录列出所有层次结构 .

    在文档根目录中,创建一个包含以下内容的 index.php

    <?php header('Location: http://example.com/qf/development/templates/webApp/');
    

    /qf/development/templates/webApp/ 中,您只需创建 index.php (禁止目录列表不会禁止文件访问, index.php 仍然是可请求的) .

相关问题