2017-04-24 140 views
0

你好朋友我有子域像exam.example.com,我需要刪除index.php從URL我的網址像exam.example.com/index.php/controller/func_name從子域URL刪除Index.php

我有以下頂替在config.php

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

更換

$config['index_page'] = ''; 

,並創建在我的項目.htaccess文件,寫了下面的代碼 -

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

檢查這個希望它可以幫助你http://stackoverflow.com/questions/29542588/remove-php-from-url/42427045#42427045 –

回答

0

我還託管了我的CodeIgniter項目之一,像您的子域一樣。我不會遇到像你這樣的問題。

我也在config.php中替換了以下內容$ config ['index_page'] ='index.php'; 替換爲$ config ['index_page'] ='';

這裏是我的.htaccess文件

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

如果你需要允許htaccess的硬道理在Apache的配置這個.htaccess文件沒有工作。 訪問Codeigniter - getting 404 Not Found error瞭解更多關於.htaccess覆蓋的信息。