【问题标题】:Problem enabling .htaccess启用 .htaccess 时出现问题
【发布时间】:2010-11-09 21:19:42
【问题描述】:

我正在尝试在我设置的 Ubuntu 服务器上启用 .htaccess 文件。我从以下位置更改了站点文件:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost

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

    [unnecessary config code omitted]

</VirtualHost>

<VirtualHost *:80>
    ServerAdmin webmaster@localhost

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

    [unnecessary config code omitted]

</VirtualHost>

现在,当我尝试在浏览器中查看页面时,我收到 500 内部服务器错误。关于我的问题可能是什么的任何想法?感谢您的帮助。

编辑

这是我的 .htaccess 文件:

RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]

我按要求检查了 apache 错误日志,似乎记录的错误是:

[2009 年 7 月 10 日星期五 19:39:12] [警报] [客户端 192.168.1.1] /var/www/document_root/.htaccess: 无效的命令“重写引擎”, 可能拼写错误或由 a 定义 模块不包含在服务器中 配置

【问题讨论】:

  • 您的 .htaccess 文件中可能存在语法错误。您能否提供 .htaccess 文件的内容,并查看 ErrorLog (/var/log/apache2/error.log)

标签: apache .htaccess


【解决方案1】:

呸...我没有启用 mod_rewrite。我觉得自己很傻。

【讨论】:

  • 我总是在这里扔一个 东西 块围绕我的重写。现在我有点好奇......如果我在你的鞋子里,这会大大延迟我弄清楚重写没有启用吗?
猜你喜欢
  • 2023-03-09
  • 2016-11-20
  • 2018-07-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-12-17
相关资源
最近更新 更多