2017-10-07 43 views
0

嗨成功取出了index.php文件在我的網址,但該[controller folder]/[function]/[argument]不工作了htaccess的笨:`[控制器]/[功能]/[參數]`不工作

這是我htacess

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

我也改變了這個

$config['uri_protocol'] = 'REQUEST_URI'; 
$config['index_page'] = ''; 

這是我的配置[ 'BASE_URL']

$base = "http://".$_SERVER['HTTP_HOST']; 
$base .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']); 
$config['base_url'] = $base; 

,我已經改變了我的http.conf Apache中 的AllowOverride所有

我也重新啓動我的XAMPP已經,CAN誰能幫我爲什麼[controller folder]/[function]/[argument]不工作?

+0

您可以按照[鏈接](https://stackoverflow.com/questions/46608887/codeigniter-3-1-6-how-to-remove -index-php-from-url/46615615#46615615)到相同的QA。 – Harish

回答

1

更新你的.htaccess腳本:

<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteBase /codeigniter 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteCond $1 !^(index\.php|images|robots\.txt|css|docs|js|system) 
    RewriteRule ^(.*)$ index.php?/$1 [L] 
</IfModule> 
+0

它不工作:(之前,它說404頁面沒有找到,現在它說沒有找到對象 –

+1

404是.htaccess錯誤,但對象未找到它可能是在控制器或模型的某處的錯誤 – Harish

+0

我試過這個RewriteEngine在 RewriteBase/codeigniter RewriteCond%{REQUEST_FILENAME}!-f RewriteCond%{REQUEST_FILENAME}!-d RewriteRule ^(。*)$ index.php?/ $ 1 [L] –

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

RewriteBase/[文件名]。

1

利用這一點避免更改RewriteBase

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