2013-03-12 3 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

相關問題