2014-12-19 68 views
0

刪除的index.php我.htaccess文件在我的根目錄:的.htaccess在笨problme從URL

RewriteEngine on 
RewriteCond $1 !^(index\.php|resources|robots\.txt) 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php/$1 [QSA,L] 

如果我使用
http://iemedica.com.ph/index.php/aboutUs它會爲我工作
但如果我使用
http://iemedica.com.ph/aboutUs其給我404錯誤

+0

您是否在Apache中啓用了mod_rewrite模塊? – Joe 2014-12-19 10:59:35

回答

1

將您的.htaccess更改爲:

RewriteEngine On 
RewriteBase/

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond $1 !^(index\.php|resources|robots\.txt) 
RewriteRule ^(.+)$ index.php?/$1 [L,QSA] 

此外,在DocumentRoot/application/config/config.php你需要有這些配置設置:

$config['base_url']  = ''; 
$config['index_page'] = ''; 
$config['uri_protocol'] = 'AUTO'; 
+0

仍然有相同的錯誤! – 2014-12-19 10:43:13

+0

您是否也在'/ application/config/config.php'中應用了更改? CI是在'DocumentRoot'還是在某個子目錄中運行? – anubhava 2014-12-19 10:48:09

+0

是的,我也應用更改和Ci在文檔根目錄中運行。 – 2014-12-19 10:53:25

0

首先你做以下更改應用程序 - > config->的config.php

   $config['base_url'] = ""; 
      $config['index_page'] = ""; 

而在.htaccess寫下面的代碼。

RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule .* /index.php/$0 [PT,L] 

這將工作。

+0

仍然有相同的錯誤! – 2014-12-19 10:59:07

+0

@amolchallawar複製上面的.htaccess代碼,並把它放在你的.htaccess中 – Raham 2014-12-19 11:02:34

+0

我的域名是http://iemedica.com.ph/... – 2014-12-19 11:07:28

0

試試這個:)

<IfModule mod_rewrite.c> 
    RewriteEngine On 
    #RewriteBase/

    RewriteCond %{REQUEST_URI} ^system.* 
    RewriteRule ^(.*)$ /index.php?/$1 [L] 

    RewriteCond %{REQUEST_URI} ^application.* 
    RewriteRule ^(.*)$ /index.php?/$1 [L] 

    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule ^(.*)$ index.php?/$1 [L] 
</IfModule> 
0

在Apache服務器允許你重寫模塊,並使用此HTA訪問

RewriteEngine on 
RewriteCond $1 !^(index.php|resources|robots.txt) 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php/$1 [L,QSA] 

複製並粘貼此代碼,並將文件保存在.htaccess的名義下你的codeigniter目錄。