[英]htaccess remove directories from url
My main problem is that i got a lot of directories that i want to hide from the customer visiting my website. 我的主要问题是我想对访问我的网站的客户隐藏很多目录。
my base url: http://example.com/qf/development/templates/webApp/ 我的基本网址: http : //example.com/qf/development/templates/webApp/
What i want to hide for the visiting customer is these directories "/qf/development/templates/" 我想为来访的客户隐藏的是这些目录“ / qf / development / templates /”
I have tried with the following in my .htaccess file in the directory http://example.com/.htaccess in the web root 我在Web根目录下的目录http://example.com/.htaccess中的.htaccess文件中尝试了以下操作
This is whats inside my .htaccess file but not working.. 这是我的.htaccess文件中的内容,但不起作用。
Options +FollowSymLinks -MultiViews 选项+ FollowSymLinks -MultiViews
RewriteEngine On RewriteEngine开
RewriteBase / RewriteBase /
RewriteRule ^qf$ qf/development/templates/webApp/index.php RewriteRule ^ qf $ qf / development / templates / webApp / index.php
My solution : 我的解决方案:
in your current .htaccess : 在您当前的.htaccess中 :
RewriteEngine off
Options -Indexes
This will prevent the directories listing of all the hierarchy from your root. 这将防止从您的根目录列出所有层次结构。
In your document root, you create a index.php containing : 在文档根目录中,创建一个index.php,其中包含:
<?php header('Location: http://example.com/qf/development/templates/webApp/');
in /qf/development/templates/webApp/
, you just create the index.php (disallowing directories listing will not disallow files access, index.php will still be requestable). 在/qf/development/templates/webApp/
,您只需创建index.php (禁止目录列表将不允许文件访问,仍然可以请求index.php )。
You can try this rule 你可以试试这个规则
RewriteEngine on
RewriteBase /
RewriteRule ^qf/?$ qf/development/templates/webApp/index.php [L,NC]
This will redirect www.example.com/qf to www.example.com/qf/development/templets/webApp/index.php 这会将www.example.com/qf重定向到 www.example.com/qf/development/templets/webApp/index.php
Or 要么
Add the following line to your .htaccess file 将以下行添加到您的.htaccess文件中
IndexIgnore *dir
This tells the Apache web server to list all files except those that is in the IndexIgnore 这告诉Apache Web服务器列出除IndexIgnore中的文件以外的所有文件
example 1 add the following line to your .htaccess file if you want to hide a directory named foo 示例1如果要隐藏名为foo的目录,请将以下行添加到.htaccess文件中
IndexIgnore *foo
example 2 add the following line to your .htaccess file if you want to hide a file that ends with .bar 示例2如果要隐藏以.bar结尾的文件,请将以下行添加到.htaccess文件中
IndexIgnore *.bar
If you want to disable all files and directories form listing ,Add this line to your .htaccess 如果要禁用所有文件和目录列表,请将此行添加到.htaccess中
IndexIgnore *
The wildcard '*' means it will not display any files 通配符“ *”表示将不显示任何文件
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.