3

亚马逊 ec2 中的codeigniter.htaccess删除 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

4 回答 4

13

您可以像这样更改您的.htaccess

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

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

进入“ AllowOverride All

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

sudo service httpd restart

它在我的 aws ec2 上有效并经过测试。

于 2013-08-15T18:57:28.323 回答
8
(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
于 2015-01-07T09:09:53.383 回答
3

贾斯汀是对的!

您也可以只对您的项目使用“ AllowOverride All ”规则;在/etc/httpd/conf/httpd.conf中写如下:

<Directory "/var/www/your_website">
    AllowOverride All
</Directory>
于 2014-03-19T02:39:41.270 回答
1

只有您可以对所有部署的应用程序使用“AllowOverride All”规则;写在 /etc/httpd/conf/httpd.conf :

 <Directory "/var/www/html">
     Options Indexes FollowSymLinks
     AllowOverride All 
     Order allow,deny
     Allow from all
 </Directory>
于 2014-06-21T09:11:46.653 回答