1 回答

TA貢獻(xiàn)1946條經(jīng)驗(yàn) 獲得超3個(gè)贊
確保啟用 apache mod_rewrite。然后重定向:
<IfModule mod_rewrite.c>
# Make sure url's can be rewritten.
RewriteEngine on
# Redirect requests that are not files or directories to index.php.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [L]
</IfModule>
這就是大多數(shù) CMS 的做法。這確實(shí)意味著如果他們將直接路徑寫(xiě)入文件,他們將看到該文件。所以你會(huì)想在這之前加上類似的東西:
# Prevent direct access to these file types.
<FilesMatch "\.(sql|md|sh|scss|rb|conf|rc|tpl(\.php)?|lib(\.php)?|wig(\.php)?|pg(\.php)?|reg(\.php)?|db(\.php)?)$">
Require all denied
</FilesMatch>
這意味著他們無(wú)法訪問(wèn)上面列出的文件擴(kuò)展名。您可以將最后幾個(gè)替換為 justrc|php但我允許訪問(wèn) .php 文件而不是 .lib 以便我可以執(zhí)行受瀏覽器身份驗(yàn)證保護(hù)的腳本以進(jìn)行調(diào)試和銀彈數(shù)據(jù)庫(kù)修復(fù)。
你還必須在你的 apache 配置中有這樣的東西,允許在你的站點(diǎn)目錄中讀取 .htaccess。
<Directory "C:/Sites">
AllowOverride All
</Directory>
- 1 回答
- 0 關(guān)注
- 89 瀏覽
添加回答
舉報(bào)