Moving Codeigniter Project to Amazon EC2, htaccess and ModRewrite Problems

╄→гoц情女王★ 提交于 2020-01-10 20:04:11

问题


I am attempting to move my Codeigniter projects from a shared hosting service to Amazon EC2 and am running into some challenges with my .htaccess settings. These settings enabled me to not have to include index.php in the url. My previous .htaccess is shown below and worked as expected with my previous hosting provider:

<IfModule mod_rewrite.c>
   RewriteEngine On
   RewriteBase /simple.com/
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
   ErrorDocument 404 /index.php
</IfModule>

With my Amazon EC2 instance, I now have full access to the LAMP stack and have confirmed that the Apache Mod_Rewrite module is enabled.

I have set up my EC2 instance with two Virtual Host directories, one for each of my sites. Both sites serve up their CI applications as expected, but require index.php to be in the url.

I've tried inserting my Amazon EC2 public path into the .htaccess file as follows but still no luck:

RewriteBase /ec2-55-27-191-14.compute-1.amazonaws.com/simple/

I am sure this is 100% user error on my part and would greatly appreciate your diagnosis!


回答1:


To answer my own question...

I wound up changing the Apache file /etc/apache/sites-available/default from AllowOverRide = None to AllowOverRide = All.




回答2:


have you also tried

RewriteBase /

or RewriteBase /simple/

or along those lines?

in my dealings on servers i've used, i've never had to put the domain into the rewrite base. Just the folders



来源:https://stackoverflow.com/questions/5479103/moving-codeigniter-project-to-amazon-ec2-htaccess-and-modrewrite-problems

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!