【发布时间】:2017-09-10 05:31:48
【问题描述】:
我在 MAMP 上本地运行 CodeIgniter 3 就好了。但是,当我从我的仓库中提取并尝试在安装了 LAMP 的 ec2 实例上设置它时,我得到一个 404。CodeIgniter 位于 /var/www/html 文件夹中
我的/etc/apache2/apache2.conf 文件包含以下内容:
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>
<Directory /var/www>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
mod_rewrite 已启用。文件/etc/apache2/sites-available/000-default.conf如下:
<VirtualHost *:80>
AccessFileName .htaccess
ServerAdmin admin@yourdomain.com
DocumentRoot /var/www/html/
<Directory />
AllowOverride All
Order allow,deny
allow from all
</Directory>
<Directory /var/www/html/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
文件/var/www/html/application/config/config.php有如下设置:
$config['index_page'] = '';
$config['base_url'] = 'http://baseurl.com';
我的.htaccess文件如下:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
【问题讨论】:
-
在 vhost 文件中设置服务器名称。您忘记了基本网址末尾的斜杠。它可以与 url 中的 index.php 一起使用吗?
-
控制器(和模型)文件名以大写开头?
标签: .htaccess codeigniter virtualhost codeigniter-3