记号化.htaccess文件记号、文件、htaccess

2023-09-02 00:44:37 作者:三分书生气七分流氓范

打赌你没有看到这一切? ;)

所以,我的一个项目需要,我专门阅读和意义超出 .htaccess文件。

不幸的是,谷歌上搜索只产生人试图获得无限的悲哀自己的的.htaccess 工作(对不起,忍不住评论)

不管怎样,我有点害怕试图让这件事情了使用它的开放源代码项目。你看,在过去的几周里,我结束了浪费的很多的时间试图解决这个策略我的问题,才发现我做的更好看的RFC和放大器;规范和建立的东西我的路。

因此​​,如果您知道一个库,或任何(希望干净!)code,它是这种情况,请不要共享。在此同时,如果你知道有关的.htaccess文件格式的文章,我相信他们会非常方便。谢谢你。

注:我是pretty的多的多语种,可以使用任何codeBase的,即使最终code将是德尔福。我知道我要求的太多了,但我很乐意看到更低的C ++。想想我的心理健康共享C ++ code之前。 :)

编辑:嗯,我想我只是要手工做我自己。文件结构似乎是:

 指令ARG1 ARG2 ARGN
<开始指令节>
< /结束指令节>
#单行注释
 

解决方案

的.htaccess语法实际上是完全相同的Apache配置本身,例如解析器确实存在吧。

如果你正在寻找写你自己的,你大多是正确的格式。请记住,段标记可以嵌套,并且可以有参数(如<位置/>)

解析英语的方法:

 对于文件中的每一行:
  从开始和行末剥离其中的空白。
  如果行开始以'#':
    解析为注释(或跳过)

  否则,如果该行以一个'<':
    如果下一个字符是'/',该行是关闭标签:
      寻找下一个>获取标签名,并从标签栈中弹出它。
    否则,该行是一个开放的标签:
      寻找下一个>为标记名称。
      如果标记,修剪,包含空格:
        拆分的第一个空格。右侧是PARAMS,左边是标签。
        (IfModule,地点等使用)

      按标记名称标记堆栈。

  否则,该行是一个指令:
    分裂空格就行了。这是该指令,而params。
 
有没有软件能把pdf格式的转化成word文档

只需加引号处理和你设置。

Bet you didn't see this coming? ;)

So, a project of mine requires that I specifically read and make sense out of .htaccess files.

Sadly, searching on Google only yields the infinite woes of people trying to get their own .htaccess to work (sorry, couldn't resist the comment).

Anyway, I'm a bit scared of trying to get this thing out of open-source projects that use it. See, in the past few weeks, I ended up wasting a lot of time trying to fix my issues with this strategy, only to find out that I did better to read RFCs & specs and build the thing my way.

So, if you know about a library, or any (hopefully clean!) code that does this, please do share. In the mean time, if you know about any articles about .htaccess file format, I'm sure they'll be very handy. Thanks.

NB: I'm pretty much multilingual and could make use of any codebase, even though the end code will be Delphi. I know I'm asking too much, but I'd love to see less of C++. Just think of my mental health before sharing C++ code. :)

Edit: Well, I think I'm just going to do this manually myself. The file structure seems to be:

directive arg1 arg2 argN
<begin directive section>
</end directive section>
# single line comment

解决方案

.htaccess grammar is actually the exact same as the Apache configuration itself, and example parsers do exist for it.

If you're looking to write your own, you are mostly correct on the format. Remember, section tags can be nested and can have parameters (like <Location />)

English method of parsing:

For each line in the file:
  Strip whitespace from beginning and end of line.
  If the line starts with a '#':
    Parse it as a comment (or skip it)

  Else, If the line starts with a '<':
    If the next character is a '/', the line is a closing tag:
      Seek to the next '>' to get the tag name, and pop it from the tag stack.
    Else, the line is an opening tag:
      Seek to the next '>' for the tag name.
      If the tag, trimmed, contains whitespace:
        Split on the first whitespace. The right side is params, left is the tag. 
        (IfModule, Location, etc use this)

      Push the tag name to the tag stack.

  Else, the line is a directive:
    Split the line on whitespace. This is the directive and params.

Just add quote handling and you're set.