繁体   English   中英

Apache RewriteRule模式不起作用

[英]Apache RewriteRule mode not working

我想重写规则以允许能力这样的路径:

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开

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]

由于我尚无法对此问题发表评论(是,因果报应),因此,我将发布较为常见的答案之一,因为这通常是由于未读取/关注.htaccess文件引起的:

“尝试将垃圾放入htaccess文件中。如果正在读取它,则在访问该资源时会收到内部服务器错误消息。如果它不会引起内部服务器错误,请参阅AllowOverride。如果AllowOverride为与Nonfatal一起使用”

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM