Tokenize.htaccess Files

See that you have not seen this ?;)

So, my project requires me to specifically read and understand the meaning . htaccess files .

Unfortunately, a Google search only gives endless troubles to people trying to get their own .htaccess to work (sorry, I could not resist the comment).

In any case, I'm a little afraid to try to get this thing from open source projects that use it. You see, over the past few weeks, I spent a lot of time fixing my problems with this strategy, only to find out that I better read RFCs and specifications and build things my own way.

So, if you know about the library or any (hopefully clean!) Code that does this, please split it up. Meanwhile, if you know about any articles about the .htaccess file format, I am sure that they will be very convenient. Thanks.

NB: I am pretty multilingual and can use any codebase, although Delphi will be the final code. I know that I ask too much, but I would like to see less C ++. Just think about my mental health before sharing C ++ code. :)

Edit: Well, I think I'll just do it manually myself. The file structure is as follows:

 directive arg1 arg2 argN <begin directive section> </end directive section> # single line comment 
+4
source share
1 answer
grammar

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

If you want to write your own, you are mostly true to the format. Remember that section tags can be nested and have parameters (e.g. <Location>)

English parsing method:

 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 processing and you will install.

+4
source

All Articles