我使用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
时,内容会按预期显示。
答案 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]