1 回答

TA貢獻1856條經(jīng)驗 獲得超11個贊
確保 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 都是這樣做的。這確實意味著如果他們將直接路徑寫入文件,他們將看到該文件。因此,您需要在此之前添加以下內(nèi)容:
# 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>
這意味著他們無法訪問上面列出的文件擴展名。您可以用 just 替換最后幾個,rc|php但我允許訪問 .php 文件而不是 .lib,這樣我就可以執(zhí)行受瀏覽器身份驗證保護的腳本來進行調(diào)試和銀彈數(shù)據(jù)庫修復。
您的 apache 配置中還必須有類似的內(nèi)容,以允許在您的站點目錄中讀取 .htaccess。
<Directory "C:/Sites">
AllowOverride All
</Directory>
- 1 回答
- 0 關注
- 155 瀏覽
添加回答
舉報