3

我安装了 apache2 的 Ubuntu 12.10,但我的 .htaccess 文件无法正常工作。我将其设置为不能在链接中包含 .php 文件扩展名,因此它看起来像 www.website.com/login 而不是 /login.php,但它说找不到 URL“/login”在服务器上。我已经阅读了这个页面,它说了一些关于“AllowOverride All”的内容,但我不知道那在哪里,或者如果我需要添加它,我会在哪里添加它。

编辑:我找到了这个链接并找到了它所说的内容,但它说我去的任何页面上都有内部服务器错误。我已将其更改为

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

但它说内部服务器错误

编辑#2:在错误日志中,它说

/var/www/.htaccess: Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration

编辑#3:在这里找到答案:.htaccess:无效命令“RewriteEngine”,可能拼写错误或由服务器配置中未包含的模块定义

4

2 回答 2

1
  • Make sure you have enabled mod_rewrite in your .htaccess.

Also make sure you these lines at the top of your .htaccess:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

i.e. turn the MultiViews options off.

Also see this Q&A for a similar problem and my answer.

于 2013-05-26T00:59:38.107 回答
0

您应该在 apache 配置中拥有或指定 Directory-block。你可以在AllowOverride这里找到文档:http ://httpd.apache.org/docs/2.2/mod/core.html#allowoverride

有关文档在<Directory>这里:http ://httpd.apache.org/docs/2.2/mod/core.html#directory

简而言之:指定您希望在哪里覆盖设置<Directory /path/to/your/directory>,然后AllowOverride all在该目录块中使用。

于 2013-05-25T21:39:24.803 回答