错误500:.htaccess RewriteCond:错误的标志分隔符 [英] Error 500: .htaccess RewriteCond: bad flag delimiters

查看:170
本文介绍了错误500:.htaccess RewriteCond:错误的标志分隔符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到了关于该问题的许多问题,但就我而言,htaccess非常简单:

I've noticed many questions about that problem, but in my case the htaccess is very simple:

<IfModule mod_rewrite.c>
RewriteEngine on

#somecomment    
RewriteBase /restAPI/   

#continue if condition is true:
RewriteCond %{REQUEST_FILENAME} !-f  # somecomment 
RewriteCond %{REQUEST_FILENAME} !-d  # somecomment 

RewriteRule ^(.+)$ index.php?url=$1 [QSA,L] 
#somecomment 
#somecomment 

</IfModule>

大约4到5周,我对重写库没有问题,但现在我不能开始我简单的RestAPI:/

4-5 weeks about now I haven't problem with that rewritebase, but now I can't start my simple RestAPI :/

任何建议为何不起作用?

Any suggestions why this doesn't work?

推荐答案

RewriteCond %{REQUEST_FILENAME} !-f  # somecomment 
RewriteCond %{REQUEST_FILENAME} !-d  # somecomment 

500错误是您行尾注释的结果。 Apache实际上并不支持行尾注释。

The 500 Error is the result of your line-end comments. Apache does not actually support line-end comments.


以哈希字符#开头的行被视为注释,并被忽略。注释不能与配置指令放在同一行。

Lines that begin with the hash character "#" are considered comments, and are ignored. Comments may not be included on the same line as a configuration directive.

参考: https://httpd.apache.org/docs/2.2/configuring.html#syntax

有时行尾注释似乎起作用,因为出现了乱码。如果将所有参数都提供给指令,那么行尾的所有内容都会被忽略。但是在这种情况下,您没有提供任何 flags (第3个参数),因此您收到错误,它试图解释您的#一些评论作为 RewriteCond 标志。

Sometimes line-end comments appear to work because of a "fluke". If you supply all the arguments to the directive then anything trailing on the line is ignored. But in this case you have not supplied any flags (the 3rd argument), so you get the error, it is trying to interpret your # somecomment as RewriteCond flags.

这篇关于错误500:.htaccess RewriteCond:错误的标志分隔符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆