2014-06-18 59 views
1

我把代碼放在.htaccess下是htaccess的代碼,也改變了config.php文件,但它仍然給404錯誤,請任何人幫我找到是什麼問題,聽到是網站http://198.12.149.211/~physrec/codeigniter刪除index.php給出404 errore

$config['base_url'] = "http://198.12.149.211/~physrec/"; 

    <IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteBase /ci_intro/ 

    #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 ^(.*)$ /ci_intro/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 ^(.*)$ /ci_intro/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 ^(.*)$ /ci_intro/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> 
+0

如果你想從你的網址中移除的index.php,然後確保做到在應用以下/配置/ config.php文件 - $配置[「index_page」 ] ='' – pankaj

+0

我只是把$ config ['index_page'] ='',但它仍然不工作 – user3751235

+0

剛纔,我點擊上面的鏈接,頁面打開,我沒有得到404錯誤。 – pankaj

回答

0
<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteBase /ci_intro/ 

    #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> 

的鏈接確認您已在httpd.conf文件下面,如果不是那麼修改的conf文件並重新啓動Apache。

<Directory /> 
    Options FollowSymLinks 
    AllowOverride All 
    Order deny,allow 
    Deny from all 
</Directory> 

此外,還要確保重寫是在你的Apache配置

+0

仍然不能正常工作 – user3751235

+0

我假設你的基目錄是'ci_intro',並且你已經在你的httpd.conf文件中啓用了mod_rewrite。 – pankaj

+0

其中我發現httpd.conf文件 – user3751235

0

更改你的.htaccess文件,

RewriteEngine on 
RewriteCond $1 !^(index\.php|[Javascript/CSS/Image root Folder name(s)]|robots\.txt) 
RewriteRule ^(.*)$ /index.php/$1 [L] 

更改從您的配置文件,

$config['index_page'] = "index.php"; 

到,

$config['index_page'] = ""; 

而且這個例子將是有益的, http://snipplr.com/view/5966/codeigniter-htaccess/