I'm not sure if this is out of scope of this project, but I wanted to use it to parse real apache configs to store them in NoSQL database so I can query some info about vhosts.
It looked great untill I hit rewrite rules/conds. Problem with Rewrite rules is that order is important.
Having this conf
RewriteEngine On
RewriteCond %{HTTP_HOST} ^([^.]+\.[^.]+)(:\d+)?$
RewriteCond /domains/domain.com/web/_ !-d
RewriteCond %{HTTP:X-Forwarded-Proto} =https
RewriteRule ^(.*)$ https://www.%1$1 [L,R=301,QSA]
RewriteCond %{HTTP_HOST} ^([^.]+\.[^.]+)(:\d+)?$
RewriteCond /domains/domain.com/web/_ !-d
RewriteCond %{HTTP:X-Forwarded-Proto} !=https
RewriteRule ^(.*)$ http://www.%1$1 [L,R=301,QSA]
I'm getting:
{
"rewritecond": [
"%{HTTP_HOST} ^([^.]+\\.[^.]+)(:\\d+)?$",
"/domains/domain.com/web/_ !-d",
"%{HTTP:X-Forwarded-Proto} =https",
"%{HTTP_HOST} ^([^.]+\\.[^.]+)(:\\d+)?$",
"/domains/domain.com/web/_ !-d",
"%{HTTP:X-Forwarded-Proto} !=https"
],
"rewriterule": [
"^(.*)$ https://www.%1$1 [L,R=301,QSA]",
"^(.*)$ http://www.%1$1 [L,R=301,QSA]"
],
"rewriteengine": "1"
}
Which is simply not possible to convert back to working config. I'm not sure what would be best approach.
I'm not sure if this is out of scope of this project, but I wanted to use it to parse real apache configs to store them in NoSQL database so I can query some info about vhosts.
It looked great untill I hit rewrite rules/conds. Problem with Rewrite rules is that order is important.
Having this conf
I'm getting:
{ "rewritecond": [ "%{HTTP_HOST} ^([^.]+\\.[^.]+)(:\\d+)?$", "/domains/domain.com/web/_ !-d", "%{HTTP:X-Forwarded-Proto} =https", "%{HTTP_HOST} ^([^.]+\\.[^.]+)(:\\d+)?$", "/domains/domain.com/web/_ !-d", "%{HTTP:X-Forwarded-Proto} !=https" ], "rewriterule": [ "^(.*)$ https://www.%1$1 [L,R=301,QSA]", "^(.*)$ http://www.%1$1 [L,R=301,QSA]" ], "rewriteengine": "1" }Which is simply not possible to convert back to working config. I'm not sure what would be best approach.