我已經設法刪除了在我的url上輸入index.php
的需求,但仍然有可能這樣做。我不希望這樣做,並希望阻止用戶能夠通過像/index.php/home
或/index.php/contact
或甚至/index.php
這樣的URL訪問我的應用程序。用CodeIgniter阻止對index.php的直接訪問
有誰知道如何做到這一點?
我已經設法刪除了在我的url上輸入index.php
的需求,但仍然有可能這樣做。我不希望這樣做,並希望阻止用戶能夠通過像/index.php/home
或/index.php/contact
或甚至/index.php
這樣的URL訪問我的應用程序。用CodeIgniter阻止對index.php的直接訪問
有誰知道如何做到這一點?
將用戶重定向在你.htaccess
寫在上面
DirectoryIndex my_new_index.php
RewriteEngine on
RewriteCond $1 !^(my_new_index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /my_new_index.php/$1 [L]
重新命名index.php
文件到my_new_index.php
如果你使用Apache,那麼就設置一個重寫規則,從index.php來/
RewriteRule ^/index\.php$/
RewriteRule ^/index\.php/(.*) /$1
正確。這裏有一個例子:
RewriteRule ^foo\.html$ bar.html
或者你可以使用變量,像這樣:
^hotsheet/(.*)$ http://www.tstimpreso.com/hotsheet/$1
所以你建議創建一個不可猜測的晦澀目錄索引名稱,所以用戶將無法猜測index.php? – Kriem 2012-04-04 14:12:36
我是OP。 :)好吧,我看到這將如何工作,但它是「通過默默無聞的安全」,不是嗎? – Kriem 2012-04-04 14:16:02
@Kriem如果它不是'index.php',你可以從php內部阻止,除非它的目錄索引我沒有看到任何其他選項,除了重命名 – safarov 2012-04-04 14:19:09