2013-03-12 97 views
0

我在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文件:如何在Apache服务器中设置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> 

然后,我改变下面一行从应用/配置/ 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文件。 :(

帮助赞赏:)

+0

我在下面的答案将解决您的问题,但为了将来的参考,您正尝试在您的文件中加载“mod_rewrite.c”,但Apache正在加载“mod_rewrite.so”。两个不同的模块。 – 2013-03-12 21:56:47

+0

该文件是'.htaccess',而不是'.hitaccess'。这可能是你问题的一部分。 – Spudley 2013-03-12 21:59:23

+0

你有没有碰运气? – 2013-03-13 14:17:15

回答

5

这里是我的好“醇信赖笨.htaccess文件:

RewriteEngine On 
    RewriteBase/
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteCond $1 !^(templates|plugins) 
    RewriteRule ^(.*)$ index.php/$1 [L] 

然后重写你的基地,无论你需要,添加您需要访问的目录(我有模板和插件),你应该很好去。

当然,也要确保Apache已启用mod_rewrite,否则您将无法获得任何地方!

+0

对于那些贬低我的人,你能解释一下为什么吗? – 2014-07-13 22:03:03

相关问题