我是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