[英]Set fake directory with htaccess
I have a directory called /admin
- the most predictable name for an admin panel. 我有一个名为
/admin
的目录-管理面板的最可预测的名称。 As of right now I have created a fake directory called /ase
using htaccess. 截至目前,我已经使用htaccess创建了一个名为
/ase
的伪目录。 When you go to the url, you have to log in to the admin panel. 当您进入网址时,您必须登录到管理面板。 When you're not logged in to
/ase
, and you visit /admin
, it will say 404 not found. 当您未登录
/ase
并访问/admin
,将显示未找到404。
My htaccess is this: 我的htaccess是这样的:
RewriteEngine On
RewriteRule ^ase admin/allseeingeye/
But people can still visit admin/allseeingeye/
to log in which is located on /admin
. 但是人们仍然可以访问
admin/allseeingeye/
来登录/admin
。 Is there a PHP script like: 是否有类似PHP的脚本:
if (url = admin/allseeingeye/) {
error 404 script
} else {
// rest of the page
}
But so the page still functions on /ase
? 但是页面仍然可以在
/ase
吗?
The script above is completely wrong but that's just to explain. 上面的脚本是完全错误的,但这只是为了说明。
You don't need a PHP script for this, you can do so in mod_rewrite
itself using a separate rule: 您不需要使用PHP脚本,可以使用单独的规则在
mod_rewrite
本身中进行操作:
RewriteEngine On
# forbid direct request to allseeingeye
RewriteCond %{THE_REQUEST} /allseeingeye/ [NC]
RewriteRule ^ - [L,R=404]
RewriteRule ^ase/?$ admin/allseeingeye/ [L,NC]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.