【发布时间】:2013-08-29 14:09:31
【问题描述】:
我想在我的服务器中在Codeigniter 旁边安装另一个脚本。问题是 Codeigniter 默认包含一个.htaccess 文件,其中包含以下代码以防止直接访问 php 文件:
# Hide all PHP files so none can be accessed by HTTP
RewriteRule (.*)\.php$ index.php/$1
如何在这段代码中添加一些例外?!
如果我的 PHP 文件位于 .htaccess 所在文件夹之外的另一个文件夹中,我应该如何例外?!
我的整个代码如下:
# set it to +Indexes
Options -Indexes
Options SymLinksIfOwnerMatch
# Set the default file for indexes
DirectoryIndex index.php
<IfModule mod_rewrite.c>
# mod_rewrite rules
RewriteEngine on
# If the file is NOT the index.php file
RewriteCond %{REQUEST_FILENAME} !index.php
# Hide all PHP files so none can be accessed by HTTP
RewriteRule (.*)\.php$ index.php/$1
# If the file/dir is NOT real go to index
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [QSA,L]
</IfModule>
# If Mod_ewrite is NOT installed go to index.php
<IfModule !mod_rewrite.c>
ErrorDocument 404 index.php
</IfModule>
【问题讨论】:
标签: .htaccess codeigniter