更新 .htaccess 檔案以限制某些頁面

更新 .htaccess 檔案以限制某些頁面

我的根 Web 伺服器中的 .htaccess 檔案是:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\?*$ index.php/$1 [L,QSA]

當我造訪 www.mysite.com/images 或 /javascript 時,會顯示目錄佈局,並顯示我的所有圖像和資產。我的應用程式入口腳本是index.php。我如何拒絕此訪問?

謝謝。

答案1

我不知道 .htaccess 或 mod_rewrite 是否是完成此任務的最佳工具。

您可以做幾件事。由於您使用的是 php,請嘗試將以下程式碼放入index.php每個子目錄中 ( javascript/index.php )

<?php header( 'Location: /' ) ; ?>

相關內容