4

我将当前的 .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

谢谢你的帮助!

4

3 回答 3

16

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

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

代替

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

谢谢!

于 2013-07-06T08:25:15.163 回答
1

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

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

<Directory />
  Options FollowSymLinks
  AllowOverride Indexes Options=All,MultiViews
  Order deny,allow
  Deny from all
</Directory>
于 2013-07-06T03:29:35.993 回答
0

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

于 2021-06-16T14:41:32.393 回答