Web 服务器未读取 .htaccess 文件 [英] Web server not reading .htaccess file

查看:50
本文介绍了Web 服务器未读取 .htaccess 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我安装了 Ubuntu 12.10 和 apache2,但我的 .htaccess 文件不起作用.我将它设置为链接中没有 .php 文件扩展名,所以它看起来像 www.website.com/login 而不是/login.php,但它说找不到 URL/login"在服务器上.我已经阅读了这个页面 并且它说了一些关于AllowOverride All"的内容,但我不知道不知道它在哪里,或者如果我需要添加它,我会在哪里添加它.

I have Ubuntu 12.10 with apache2 installed, and my .htaccess file is not working. I have it set up to be able to not have .php file extensions in the links, so it looks like www.website.com/login instead of /login.php, but it says that the URL "/login" is not found on the server. I have read this page and it says something about "AllowOverride All" but I don't know where that is, or if I need to add it, where I would add it.

我找到了这个链接并找到了它说的是什么,但它说我去的任何页面上都有内部服务器错误.我已经改成

I have found this link and have found what it says, but it says that I have an Internal Server Error on any page I go to. I have changed the to

<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",可能拼写错误或由未包含在服务器配置中的模块定义

推荐答案

  • 确保您在 .htaccess 中启用了 mod_rewrite.
  • 还要确保在 .htaccess 的顶部有这些行:

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

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

    即关闭 MultiViews 选项.

    另见此问答 对于类似的问题和我的回答.

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

    这篇关于Web 服务器未读取 .htaccess 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆