簡體   English   中英

使用htaccess設置假目錄

[英]Set fake directory with htaccess

我有一個名為/admin的目錄-管理面板的最可預測的名稱。 截至目前,我已經使用htaccess創建了一個名為/ase的偽目錄。 當您進入網址時,您必須登錄到管理面板。 當您未登錄/ase並訪問/admin ,將顯示未找到404。

我的htaccess是這樣的:

RewriteEngine On
RewriteRule ^ase admin/allseeingeye/

但是人們仍然可以訪問admin/allseeingeye/來登錄/admin 是否有類似PHP的腳本:

if (url = admin/allseeingeye/) {
    error 404 script
} else {
    // rest of the page
}

但是頁面仍然可以在/ase嗎?

上面的腳本是完全錯誤的,但這只是為了說明。

您不需要使用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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM