本文介绍了htaccess的不工作在Amazon EC2上的Ubuntu实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一台服务器从Linux操作系统Ubuntu上运行(Amazon的EC2服务Ubuntu服务器13.04 64位)和我已经安装了Apache,PHP和MySQL。我在我的文档根目录添加.htaccess文件(即在/ var / WWW /)。

I have a server from amazon's ec2 service running on Linux Ubuntu (Ubuntu Server 13.04 64 bit) and I have installed apache, php, and mysql. I have added a .htaccess file in my document root (i.e /var/www/).

下面是code。在.htaccess文件如下:

Here is the code in .htaccess file as follows:

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php

如果我删除的.php的网址,如索引1,而不是index1.php,则返回404浏览器的错误。它工作正常在我的previous服务器。

If I remove .php from url like "index1" instead of "index1.php", it returns 404 browser error. It works properly in my previous server.

我的.htaccess在服务器上启用。我这样做是使用命令须藤的vim的/ etc / apache2的/站点可用/默认,改变设置AllowOverride无到设置AllowOverride全部。

I have .htaccess enabled in server. I did it using command "sudo vim /etc/apache2/sites-available/default" and changed "AllowOverride None" to "AllowOverride All".

我还检查的.htaccess通过传递无效值htaccess文件工作,返回内部服务器错误 - 500在浏览器中。

I have also checked .htaccess working by passing invalid value in htaccess file and it returns "Internal server error - 500" in browser.

下面是我的服务器信息的链接: http://54.200.58.45/mytest.php

Here is the link of my server information : http://54.200.58.45/mytest.php

任何帮助在这方面将是非常美联社preciated。

Any help in this regard will be highly appreciated.

推荐答案

这是因为重写模块不来默认启用出于安全考虑。

This happens because the rewrite module doesn’t come enabled by default for security reasons.

创建一个名为 rewrite.conf 的/ etc / apache2的/ MODS启用新文件在文件中把这个行的LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so

Create a new file called rewrite.conf in /etc/apache2/mods-enabledin the file put this line LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so

现在重装服务器须藤服务的Apache2重启

这工作对我来说,希望对你,但我不劝告这对生产服务器。这是信息定期Ubuntu用户不是一个活的服务器。

This worked for me and hopefully for you, but I don’t advice this for production servers. This is information for regular Ubuntu users not for a live server.

这篇关于htaccess的不工作在Amazon EC2上的Ubuntu实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-07 06:57