我在 Windows 7 操作系统上安装了 Apache 2.2、Php 5.4.5 和 Mysql 5.5.27。我的本地主机位置是 G:/local_server。我已经下载了 CodeIgniter_2.1.3 并解压到 local_server 并重命名 CodeIgniter。我在 CodeIgniter 文件夹中创建了一个 .htaccess 文件,并通过以下代码:
<IfModule mod_rewrite.c>
# Turn on URL rewriting
RewriteEngine On
# If your website begins from a folder e.g localhost/my_project then
# you have to change it to: RewriteBase /my_project/
# If your site begins from the root e.g. example.local/ then
# let it as it is
RewriteBase / CodeIgniter/
# Protect application and system files from being viewed when the index.php is missing
RewriteCond $1 ^(application|system|private|logs)
# Rewrite to index.php/access_denied/URL
RewriteRule ^(.*)$ index.php/access_denied/$1 [PT,L]
# Allow these directories and files to be displayed directly:
RewriteCond $1 ^(index\.php|robots\.txt|opensearch\.xml|favicon\.ico|assets|forums)
# No rewriting
RewriteRule ^(.*)$ - [PT,L]
# Rewrite to index.php/URL
RewriteRule ^(.*)$ index.php/$1 [PT,L]
</IfModule>
然后我从 application/config/config.php 更改了以下行
$config['index_page'] = 'index.php'; to $config['index_page'] = '';
$config['uri_protocol'] = 'AUTO'; to $config['uri_protocol'] = 'REQUEST_URI';
我还从 Apache httpd.conf 中删除了 # 以下行:
LoadModule rewrite_module modules/mod_rewrite.so
但我仍然无法从 CodeIgniter 中隐藏 index.php 文件。:(
帮助表示赞赏。:)