2017-05-21 67 views
1

我有一些問題。在開發中,我使用的是PHP 7,而且我的網站運行良好。但在生產中它使用PHP 5.4和我在刪除index.php時遇到問題。我的網站託管在子文件夾中,就像myhost/mywebsitefolder刪除子文件夾代碼點火器中的index.php

問題是使用url函數時。例如,當我訪問「儀表板」頁面時,它將重定向到「登錄」頁面,並且該URL類似於myhost/mywebsitefolder/login,並且它返回404頁面未找到。當我登錄之前添加index.php(myhost/mywebsitefolder/index.php/login)它工作正常,但我必須通過添加index.php來替換我的所有網址。有沒有解決辦法。我的.htaccess就是這樣。

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

用線'重寫規則^加問號嘗試$指數.php?/ $ 1 [L,QSA]'。 – Tpojka

回答

1

以斜線嘗試點之前,如:

DirectoryIndex index.php 

<IfModule mod_rewrite.c> 

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

</IfModule> 

<IfModule !mod_rewrite.c> 
    ErrorDocument 404 index.php 
</IfModule> 

而且在的application/config/config.php文件並清除索引頁配置值:

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

// New 
$config['index_page'] = ""; 

有時你需要啓用它的重寫模塊,運行「apache2 enable module rewrite」:

sudo a2enmod rewrite 

您需要重新啓動Web服務器以應用更改:

sudo service apache2 restart 

希望工程!

如果沒有,有其他的線程有同樣的問題,你可以去看看:(。*) - Remove index.php from codeigniter in subfolder - - Remove index.php from Codeigniter URL in subfolder with Wordpress in root Using htaccess to remove codeigniter index.php in a subdirectory

+0

謝謝,問題出在我認爲的我的apache模塊中 –

相關問題