【发布时间】:2015-07-04 19:05:15
【问题描述】:
我在 windows(XAMPP) 中使用 codeiginiter 完成了一个项目,现在我将操作系统更改为 UBUNTU 14.04,并且我已经安装了 LAMP,LAMP 工作正常。
我将我的项目文件复制到 /var/www/html 并将所有配置更改为 ububtu
$config['base_url'] = 'http://localhost/lankaproperty/';
$config['index_page'] = 'index.php';
路线
$route['default_controller'] = 'welcome';
$route['404_override'] = 'home/error_404';
$route['500_override'] = 'home/error_500';
$route['translate_uri_dashes'] = FALSE;
.htaccess
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php?/$0 [PT,L]
我也把所有的文件权限都改成了755..
当我尝试这样的默认控制器时 http://localhost/lankaproperty/ 它工作正常..
但其他控制器都没有工作
http://localhost/lankaproperty/home
http://localhost/lankaproperty/index.php?/home
我得到了错误。
` 404 页面未找到
未找到您请求的页面。 ` 有人可以帮我解决这个问题 tnx..
etc/apache2/apache2.conf
# Sets the default security model of the Apache2 HTTPD server. It does
# not allow access to the root filesystem outside of /usr/share and /var/www.
# The former is used by web applications packaged in Debian,
# the latter may be used for local directories served by the web server. If
# your system is serving content from a sub-directory in /srv you must allow
# access here, or in any related virtual host.
<Directory />
Options FollowSymLinks
AllowOverride All
Require all denied
</Directory>
<Directory /usr/share>
AllowOverride All
Require all granted
</Directory>
<Directory /var/www/html>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
sites-enabled/000-default.conf
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
sites-avalible/000-default.conf
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
【问题讨论】:
-
您是否尝试在路由中添加
$route['home'] = "home/index";home 将是控制器名称 -
是试过了,但还是一样的404错误。
-
是的,我也试过不带问号。没有变化..
-
谢谢大家。我从 codeiginiter 3.0 迁移到 codeiginiter 2.2.. 现在一切正常..
标签: php .htaccess codeigniter ubuntu