I have 2 subdomains that use the same rules as below:
<Directory /srv/project/sites/project.hu/htdocs/>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\?*$ index.php?route=$1 [L,QSA]
SetEnv config default,local
Order allow,deny
allow from 192.168.0.0/16
</Directory>
<Directory /srv/project/sites/admin.project.hu/htdocs/>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\?*$ index.php?route=$1 [L,QSA]
SetEnv config default,local
Order allow,deny
allow from 192.168.0.0/16
</Directory>
As you can see, the rules are the same in both containers. How can I specify these rules in one container? At first I thought about this:
<DirectoryMatch ^/srv/project/sites/(?:(?:admin\.project\.hu)|project\.hu)/htdocs/$>
...
</DirectoryMatch>
But is there no way to do this in a cleaner way that I am missing?
Edit: I don't like the DirectoryMatch path, because when I have more directories, the regex will grow unattainable.
source
share