【问题标题】:problem with .htaccess file.htaccess 文件的问题
【发布时间】:2011-10-03 04:46:34
【问题描述】:

我面临一个关于我的 .htaccess 文件的问题,这里是文件中的代码

<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteRule ^category/([^/\.]+)/?$ index.php?category=$1 [L]
RewriteRule ^department/([^/\.]+)/?$ index.php?department=$1 [L]
RewriteRule ^brand/([^/\.]+)/?$ index.php?brand=$1 [L]
RewriteRule ^product/([^/\.]+)/?$ index.php?product=$1 [L]
RewriteRule ^basket/([^/\.]+)/?$ index.php?basket=$1 [L]
</IfModule> 

一旦我加载网站,它就会给我这个错误

Internal Server Error

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

Please contact the server administrator, root@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 文件内容,网站就会恢复正常工作

【问题讨论】:

  • 这是因为选项 +FollowSymLinks,一旦我将其删除,它就可以正常工作了,谢谢

标签: php .htaccess mod-rewrite apache2


【解决方案1】:

那些“内部服务器错误”消息让人头疼;它们几乎和没有错误消息一样没用。

.htaccess 文件的调试程序:

  1. 注释掉每一行。
  2. 取消注释第一行注释。
  3. 试试看。
  4. 有效吗?转到第 2 步
  5. 不起作用?查看服务器的日志以获取更多详细信息。

【讨论】:

    【解决方案2】:

    请检查此目录是否配置了AllowOverride 设置为OptionsAll

    【讨论】:

    • 我无法访问其共享主机的根帐户
    • 关于您自己的评论,您可以假设该目录未配置为允许覆盖选项,因此服务器错误是尝试执行不允许的操作的结果。
    【解决方案3】:

    确保您已使用正确的编码保存了您的 .htaccess 文件:我建议使用 ANSI,因为如果不是这样,apache 可能会出现问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-16
      相关资源
      最近更新 更多