2017-05-24 350 views
0

在我的服務器上託管codeigniter網站時,第一頁顯示正常,其他鏈接顯示錯誤,如下所示。在此服務器上找不到請求的URL

未找到

所請求的網址/網站/ ourservices此服務器上未找到。

此外,在嘗試 使用ErrorDocument來處理請求時遇到404未找到錯誤。

如何排序?我是一名初學者。

+0

您的網絡服務器可能被錯誤地配置爲處理URL重寫。 – thepieterdc

回答

0

這些行添加到的.htaccess:(基於codeigniter urls docs

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

你有Site.php控制器在/application/controllers文件夾?

或者,您是否有指向現有控制器/功能的路線?

下列任一兩種方法之一:

  1. 創建一個控制器,並將其命名爲/application/controller/Site.php。您可以複製Welcome.php控制器以快速創建文件。然後將類的名稱更改爲Site而不是Welcome。現在,添加在裏面的功能,並命名爲public function ourservices()

- 或 -

  • 轉到您的/application/config/routes.php文件,並在裏面添加路由檢查「網站/ ourservices 「並將其指向現有控制器中的某個功能。即$route['site/ourservices'] = 'Welcome/ourservices';,只要您在/application/controllers/Welcome.php控制器中具有稱爲public function ourservices()的功能即可。
  • 在你的控制器中新創建的函數,調用相應的視圖:$this->load->view('location/of/view/file')這將嘗試加載現有文件/application/views/location/of/view/file.php。確保這個文件存在。

    0

    添加這些線在你的.htaccess(項目根目錄):

    RewriteEngine On 
    RewriteBase /yoursite 
    
    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] 
    
    +0

    RewriteBase/your-site-directory(如果不是apache默認的) –

    0

    我會幫你..我前幾天遇到這個問題.. 嘗試包括以下代碼的.htaccess文件。

    RewriteEngine On 
    RewriteCond %{REQUEST_URI} ^/system.* 
    RewriteRule ^(.*)$ index.php?/$1 [L] 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule ^(.+)$ index.php?/$1 [L] 
    ErrorDocument 404 index.php 
    
    相關問題