Apache mass virtual hosts and lower case letters

A Web Developer based in Belgium, specialized in PHP & JS development
Search for a command to run...

A Web Developer based in Belgium, specialized in PHP & JS development
No comments yet. Be the first to comment.
I recently needed to collect all changes in one file for reporting purposes. Found this article: https://ratfactor.com/cards/git-diff-with-new-files In case you need something similar on Windows, here

Some projects start with a grand plan. Others start because you just need to read a file without thinking too much about it. That was the case for spread-compat. I needed a common interface for CSV, X

With modern css, you can almost get rid of sass. But there is one last pain point : media queries. Not being able to use variables or an easy, common syntax for typical breakpoints is really annoying. That is, until you meet Media Queries Level 5. I’...

This is a quick article to share this demo I just made. https://codepen.io/lekoalabe/pen/JoPNWpX

Modals are typical UI elements for many web apps. There are countless packages dedicated to that specific features, each framework creating its own variation. Popular frameworks like Bootstrap also have custom code to deal with it. But all this feels...

Just in case you thought having a path starting with c:/ or C:/ was the same... let me tell you how wrong you are.
I've been migrating all my local websites to a new computer, with a fresh install of WAMPServer (yes, I'm not a big docker & co fan). I used to configure my website with a nice little snippet to automatically create all my vhosts like this:
#
# Dynamic Virtual Host Definitions
#
<IfModule mod_vhost_alias.c>
# example.com --> /var/www/vhosts/example.com/www
# www.example.com --> /var/www/vhosts/example.com/www
# a.www.example.com --> /var/www/vhosts/example.com/a.www
# shop.example.com --> /var/www/vhosts/example.com/shop
<VirtualHost *:80>
ServerName sub.domain
ServerAlias *.*.*
VirtualDocumentRoot "D:/www/%-2.0.%-1.0/%-3"
</VirtualHost>
<VirtualHost *:80>
ServerName bare.domain
ServerAlias *.*
VirtualDocumentRoot "D:/www/%-2.0.%-1.0/www"
</VirtualHost>
<VirtualHost *:80>
ServerName sub.domain
ServerAlias *.*.*
VirtualDocumentRoot "D:/www/%-2.0.%-1.0/%-3"
SSLCertificateFile "D:/wamp64/bin/apache/apache2.4.51/conf/key/localhost/server.crt"
SSLCertificateKeyFile "D:/wamp64/bin/apache/apache2.4.51/conf/key/localhost/server.key"
SSLEngine on
</VirtualHost>
<VirtualHost *:80>
ServerName bare.domain
ServerAlias *.*
VirtualDocumentRoot "D:/www/%-2.0.%-1.0/www"
SSLCertificateFile "D:/wamp64/bin/apache/apache2.4.51/conf/key/localhost/server.crt"
SSLCertificateKeyFile "D:/wamp64/bin/apache/apache2.4.51/conf/key/localhost/server.key"
SSLEngine on
</VirtualHost>
<VirtualHost *:8000>
ServerName sub.domain
ServerAlias *.*.*
VirtualDocumentRoot "D:/www/%-2.0.%-1.0/%-3/public"
</VirtualHost>
<VirtualHost *:8000>
ServerName sub.domain
ServerAlias *.*.*
VirtualDocumentRoot "D:/www/%-2.0.%-1.0/%-3/public"
SSLCertificateFile "D:/wamp64/bin/apache/apache2.4.51/conf/key/localhost/server.crt"
SSLCertificateKeyFile "D:/wamp64/bin/apache/apache2.4.51/conf/key/localhost/server.key"
SSLEngine on
</VirtualHost>
<VirtualHost *:8000>
ServerName bare.domain
ServerAlias *.*
VirtualDocumentRoot "D:/www/%-2.0.%-1.0/www/public"
</VirtualHost>
<VirtualHost *:8000>
ServerName bare.domain
ServerAlias *.*
VirtualDocumentRoot "D:/www/%-2.0.%-1.0/www/public"
SSLCertificateFile "D:/wamp64/bin/apache/apache2.4.51/conf/key/localhost/server.crt"
SSLCertificateKeyFile "D:/wamp64/bin/apache/apache2.4.51/conf/key/localhost/server.key"
SSLEngine on
</VirtualHost>
</IfModule>
This allows me to map mywebsite.local to D:/www/mywebsite.local/ (and to the "public" folder if I'm using port 8000). This worked quite well, until my recent migration.
In the snippet above, I was using a lowercase "d" instead. All the websites work, but as soon as you get a mod rewrite rule, you get an infinite loop resulting in an error 500. I scratched my head for a while, tried an older version of apache... nothing worked.
Until... I tried to rename the lowercase "d:/" to a "D:/"... and it worked! Why? I don't know ! Probably some odd bug that take case into account when interpreting mod rewrite rules.