codeigniter .htaccess在亚马逊ec2中删除index.php不能正常工作

时间:2013-06-13 06:10:32

标签: php codeigniter amazon-ec2

codeigniter .htaccess在amazon ec2中删除index.php无法正常工作

RewriteEngine on
RewriteBase http://ec2-xx-xxx-xx-xx.us-west-2.compute.amazonaws.com/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]

配置文件

$config['base_url'] = 'http://ec2-xx-xxx-xx-xx.us-west-2.compute.amazonaws.com/';

4 个答案:

答案 0 :(得分:12)

您可以像这样更改 .htaccess

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]

并在 /etc/httpd/conf/httpd.conf 上更改“ AllowOverride无”的值(如果您使用的是AMI Linux)

进入“ AllowOverride All

之后重启你的apache用这样的命令:

sudo service httpd restart

这是我的aws ec2的工作和测试。

答案 1 :(得分:3)

Justudin是对的!

您还可以使用" AllowOverride All "只统治你的项目;用 /etc/httpd/conf/httpd.conf 写这样的东西:

<Directory "/var/www/your_website">
    AllowOverride All
</Directory>

答案 2 :(得分:3)

(if you use ubuntu)
Activate the mod_rewrite module with

     sudo a2enmod rewrite

and restart the apache

     sudo service apache2 restart

To use mod_rewrite from within .htaccess files (which is a very common use case), edit the default VirtualHost with

     sudo nano /etc/apache2/sites-available/000-default.conf

Search for “DocumentRoot /var/www/html” and add the following lines directly below:

    <Directory "/var/www/html">
        AllowOverride All
    </Directory>

Save and exit the nano editor via CTRL-X, “y” and ENTER.

Restart the server again:

     sudo service apache2 restart

答案 3 :(得分:1)

只有你可以使用&#34; AllowOverride All&#34;规则适用于所有部署的应用在/etc/httpd/conf/httpd.conf中写道:

 <Directory "/var/www/html">
     Options Indexes FollowSymLinks
     AllowOverride All 
     Order allow,deny
     Allow from all
 </Directory>