[英]Blocking direct access to index.php with CodeIgniter
我已经设法消除了在我的网址中输入index.php
的需要,但仍然可以这样做。 我不希望这样,并希望阻止用户通过 /index.php/home 或/index.php/contact
甚至/index.php/home
等网址访问我的应用/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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.