从dev到live的HTACCESS错误500

时间:2014-08-27 15:53:46

标签: .htaccess

我使用MAMP在本地构建了一个我现在放在实时服务器上的网站。现在,每当我转到其中一个格式化的URL时,它都会返回错误500,但是当以原始格式访问链接时,它们会起作用。

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
RewriteRule ^(.*)$ $1.php

RewriteRule ^api/clients/company/([^/]+)?$ api/clients/company.php?id=$1 [L]
RewriteRule ^api/clients/([^/]+)/?$ api/clients/index.php?id=$1 [L]

现在,当我访问http://domain.com/api/clients/company/all时,它会返回错误500,但当我查看http://domain.com/api/clients/company.php?id=all时,内容会按预期显示。

1 个答案:

答案 0 :(得分:1)

您的规则RewriteRule ^(.*)$ $1.php与所有内容相匹配 将最后两个规则放在之前。

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]

RewriteRule ^api/clients/company/([^/]+)?$ /api/clients/company.php?id=$1 [L]
RewriteRule ^api/clients/([^/]+)/?$ /api/clients/index.php?id=$1 [L]

RewriteRule ^(.*)$ /$1.php [L]