我是CodeIgniter的新手,我開發了一個使用它的小網站。我的網站在 localhost
中工作正常。但是當我將我的網站移動到Web服務器時,第一個Welcome控制器工作正常,因爲我得到了我的第一個登錄頁面。當我點擊我的登錄(Welcome/login
)。它提供了404 error
(託管服務器404頁面)。即使它沒有給出任何驗證錯誤。當我在服務器託管我的網站時出現404錯誤
我主持這個在一個子域(www.subdomain.example.com
) 和我改變了base_url,就像這個域名。使用HTACCESS
文件重寫網址。
我將$index_page=「index.php」
更改爲$index_page=」「
,用於從URL中刪除index.php。 這在localhost中運行良好。在服務器上,我檢查了$ index_page,然後它給出了CodeIgniter 404錯誤頁面。
與我的本地主機的唯一區別是,我託管它在一個子域。這可能是問題.htaccess
,它看起來像這樣:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase/
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin
ErrorDocument 404 /index.php
</IfModule>'
您需要提供更多信息。發佈您的.htaccess文件,對於初學者,以及您嘗試在主機上訪問的路徑(您說有一個子域)。 – regulatethis
RTM - > http://ellislab.com/codeigniter/user-guide/general/urls.html – Sparky