问题描述
我正在尝试将我的 Codeigniter 项目从共享托管服务迁移到 Amazon EC2,但我的 .htaccess 设置遇到了一些挑战.这些设置使我不必在 url 中包含 index.php.我以前的 .htaccess 如下所示,并且与我以前的托管服务提供商一起按预期工作:
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>
通过我的 Amazon EC2 实例,我现在可以完全访问 LAMP 堆栈并确认已启用 Apache Mod_Rewrite 模块.
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.
我已经使用两个虚拟主机目录设置了我的 EC2 实例,一个用于我的每个站点.两个站点都按预期提供其 CI 应用程序,但要求在 url 中包含 index.php.
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.
我尝试将我的 Amazon EC2 公共路径插入到 .htaccess 文件中,如下所示,但仍然没有运气:
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/
我确信这是我 100% 的用户错误,非常感谢您的诊断!
I am sure this is 100% user error on my part and would greatly appreciate your diagnosis!
推荐答案
回答我自己的问题...
To answer my own question...
我最终将 Apache 文件/etc/apache/sites-available/default 从 AllowOverRide = None 更改为 AllowOverRide = All.
I wound up changing the Apache file /etc/apache/sites-available/default from AllowOverRide = None to AllowOverRide = All.
这篇关于将 Codeigniter 项目移至 Amazon EC2、htaccess 和 ModRewrite 问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!