2013-02-19 118 views
0

我已經在windows server 2008 R2上安裝了PHP,Mysql和Apache,正如this link所提供的。CodeIgniter正常安裝Apache 2.4後刪除index.php與htaccess 2.4

它的工作就像一個魅力,但問題是我的.htaccess刪除index.php

.htaccess文件包括以下內容:

<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteBase /HR/ #Removes access to the system folder by users. 
    #Additionally this will allow you to create a System.php controller, 
    #previously this would not have been possible. 
    #'system' can be replaced if you have renamed your system folder. 
    RewriteCond %{REQUEST_URI} ^system.* 
    RewriteRule ^(.*)$ /index.php?/$1 [L] 

    #When your application folder isn't in the system folder 
    #This snippet prevents user access to the application folder 
    #Submitted by: Fabdrol 
    #Rename 'application' to your applications folder name. 
    RewriteCond %{REQUEST_URI} ^application.* 
    RewriteRule ^(.*)$ /index.php?/$1 [L] 

    #Checks to see if the user is attempting to access a valid file, 
    #such as an image or css document, if this isn't true it sends the 
    #request to index.php 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule ^(.*)$ index.php?/$1 [L] 
</IfModule> 

<IfModule !mod_rewrite.c> 
    # If we don't have mod_rewrite installed, all 404's 
    # can be sent to index.php, and everything works as normal. 
    # Submitted by: ElliotHaughin 

    ErrorDocument 404 /index.php 
</IfModule> 

我已經在Apache中啓用mod_rewrite。但我得到500內部服務器錯誤。

注:在文檔根改變AllowOverRide AllNone喜歡這裏:

# AllowOverride controls what directives may be placed in .htaccess files. 
    # It can be "All", "None", or any combination of the keywords: 
    # Options FileInfo AuthConfig Limit 
    # 
    AllowOverride None 

500 internal error消失,但.htaccess不起作用!那麼我應該添加index.php的鏈接工作。

注:當AllowIverRide All我得到這個錯誤:

[Tue Feb 19 18:20:10.988018 2013] [core:alert] [pid 3940:tid 844] 
[client 127.0.0.1:49513] C:/Apache24/htdocs/HR/.htaccess: 
RewriteBase takes one argument, the base URL of the per-directory context 

任何幫助將不勝感激。 TY。

+0

您是否編輯config.php並將config ['index_page']更改爲等於「」?如果仍然說「index.php」,可能是你的問題。 – 2013-02-19 15:12:54

+0

如果您刪除了'RewriteBase/HR /',並且還刪除了所有'index.php'實例前面的正斜槓,會發生什麼? – Mudshark 2013-02-19 15:22:14

+0

@DevinYoung是的,我沒有刪除它.. – 2013-02-19 15:22:56

回答

1

完全沒有完全改變你的.htaccess,但這裏是我使用的一個例子,我從來沒有任何問題。這只是關於modrewrite的一部分:

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

好吧,就是這樣...謝謝。我只需編輯rewritebase併爲其添加/ HR ...再次感謝。 – 2013-02-19 15:45:54

+0

沒問題,很高興我能幫忙! – 2013-02-19 15:46:58