简体   繁体   English

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

[英]codeigniter .htaccess in amazon ec2 removal of index.php not working

codeigniter .htaccess in amazon ec2 removal of index.php not working codeigniter .htaccess在亚马逊ec2中删除index.php不能正常工作

code

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 file 配置文件

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

You can change your .htaccess like this 您可以像这样更改.htaccess

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

and change the value of " AllowOverride None " on /etc/httpd/conf/httpd.conf (if you use AMI Linux) 并在/etc/httpd/conf/httpd.conf上更改“ AllowOverride None ”的值(如果使用AMI Linux)

into " AllowOverride All " 进入“ AllowOverride All

after that restart your apache with command like this: 之后用这样的命令重新启动你的apache:

sudo service httpd restart

It's work and tested on my aws ec2. 它的工作和我的aws ec2测试。

(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

Justudin is correct! Justudin是对的!

Also you can use the " AllowOverride All " rule to only your project; 您也可以将“ AllowOverride All ”规则仅用于您的项目; writing in /etc/httpd/conf/httpd.conf something like this: /etc/httpd/conf/httpd.conf中写这样的东西:

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

Only you can use the "AllowOverride All" rule to all deployed application; 只有您可以对所有已部署的应用程序使用“AllowOverride All”规则; writing in /etc/httpd/conf/httpd.conf : 在/etc/httpd/conf/httpd.conf中编写:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM