【问题标题】:.htaccess working locally, but not on 1and1 server.htaccess 在本地工作,但不在 1and1 服务器上
【发布时间】:2013-07-04 04:08:24
【问题描述】:

我将当前的 .htaccess 文件上传到 1and1 服务器(实际上是 1und1.de,但我猜是一样的),我收到 500 Internal Server Error。

Options -MultiViews 
RewriteEngine On
RewriteBase /lammkontor

RewriteRule ^categories/([^/\.]+)/?$ index.php?url=category.php&cat_url=$1 [L]
RewriteRule ^categories/([^/\.]+)/([^/\.]+)/?$ index.php?url=product.php&cat_url=$1&prod_url=$2 [L]
RewriteRule ^categories/([^/\.]+)/([^/\.]+)/recipes?$ index.php?url=recipes.php&cat_url=$1&prod_url=$2 [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+\.php)/?$ index.php?url=$1 [QSA]

这个 .htaccess 在我的本地 MAMP 服务器上完美运行。

当我使用示例文件在控制中心测试 CGI-Monitor 时,我得到 - cgi: File not present or has invalid modes (no output)

现在唯一工作的文件是 index.php

感谢您的帮助!

【问题讨论】:

  • 查看你的 apache 日志,它通常会告诉你更多关于为什么会出现 500 错误的细节。
  • 1.通过访问文件 url 确保文件确实存在。 2. 确保文件具有正确的权限。如果 1 有效,那么 2 应该没问题。
  • 尝试删除Options -MultiViews,看看你是否仍然得到500错误,然后它没有得到500,你的httpd.conf中可能存在配置差异
  • RewriteBase /lammkontor ?您的测试站点在此子文件夹中?

标签: apache .htaccess mod-rewrite rewrite


【解决方案1】:

在网址前加一个斜线。例如 /index.php 而不是在规则末尾的 index.php

【讨论】:

    【解决方案2】:

    实际上我解决了我的问题,在每个重写规则的开头添加一个斜杠,例如:

    RewriteRule ^(.+\.php)/?$ /index.php?url=$1 [QSA]
    

    而不是

    RewriteRule ^(.+\.php)/?$ index.php?url=$1 [QSA]
    

    谢谢!

    【讨论】:

      【解决方案3】:

      默认情况下,apache 的htaccess 权限是关闭或受限的,具体取决于您的主机。 我怀疑是你的Options -MultiViews 导致了错误。

      检查您的httpd.conf 并检查MultiViews 是否被允许,如下所示。

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2017-06-12
        • 1970-01-01
        • 2020-08-14
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多