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

pre*_*ics 3 php codeigniter amazon-ec2

codeigniter .htaccess在亚马逊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]
Run Code Online (Sandbox Code Playgroud)

配置文件

$config['base_url'] = 'http://ec2-xx-xxx-xx-xx.us-west-2.compute.amazonaws.com/';
Run Code Online (Sandbox Code Playgroud)

jus*_*din 12

您可以像这样更改.htaccess

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
Run Code Online (Sandbox Code Playgroud)

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

进入" AllowOverride All "

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

sudo service httpd restart
Run Code Online (Sandbox Code Playgroud)

它的工作和我的aws ec2测试.


Har*_*iya 5

(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
Run Code Online (Sandbox Code Playgroud)