【问题标题】:Adding .htaccess makes Internal Server Error添加 .htaccess 会导致内部服务器错误
【发布时间】:2013-07-14 12:21:00
【问题描述】:

您好,我正在尝试从 url 中删除 .php 扩展名。为此,我正在关注本教程remove .php extension。但是当我将.htaccess 文件添加到目录时,它会显示

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, admin@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

我的.htaccess 文件是:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/$ $1.php
RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]

怎么了?

注意:我正在 WAMP 服务器中测试我的所有文件。

【问题讨论】:

  • 是否启用了 mod_rewrite?
  • 你检查过apache error log 使用 wampmanager 菜单查看它像这样left click wampmanager -> Apache -> Apache error log

标签: php .htaccess wamp internal-server-error


【解决方案1】:

删除下面一行之前的#

编辑前

#LoadModule rewrite_module modules/mod_rewrite.so

修改后

LoadModule rewrite_module modules/mod_rewrite.so

【讨论】:

    【解决方案2】:

    选项 +SymLinksIfOwnerMatch 线是该错误的主要原因 请评论为

    #Options +SymLinksIfOwnerMatch 
    

    错误将被删除

    【讨论】:

      【解决方案3】:

      要解决此问题,您需要启用mod rewrite 打开终端打印sudo a2enmod rewrite 然后重启apachesudo service apache2 restart

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2015-11-23
        • 2014-06-12
        • 2013-02-07
        • 2010-10-07
        • 2014-12-14
        • 1970-01-01
        • 2017-07-05
        • 2019-04-15
        相关资源
        最近更新 更多