我想重写规则,以便能够像这样的路径:
http://example.com/api/somemethod/ Api是一个包含api类的api.php文件。
我已经在.htaccess中重写了规则,但如果我尝试在上面进行链接,则会收到错误:
Object not found! The requested URL was not found on this server. If
you entered the URL manually please check your spelling and try again.
If you think this is a server error, please contact the webmaster.
Error 404
这是我的.htaccess文件:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-s
RewriteRule ^(.*)$ api.php?x=$1 [QSA,NC,L]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.*)$ api.php [QSA,NC,L]
RewriteCond %{REQUEST_FILENAME} -s
RewriteRule ^(.*)$ api.php [QSA,NC,L]
答案 0 :(得分:0)
由于我还不能评论这个问题(yay karma),我会发布一个更常见的答案,因为这通常是由.htaccess文件没有被阅读/遵循引起的:
“尝试将垃圾放入你的htaccess文件中。如果正在阅读,你会的 访问该资源时出现内部服务器错误。如果它 不会导致内部服务器错误,请参阅AllowOverride。这不会 如果AllowOverride与Nonfatal“
一起使用,则从2.4开始工作