Forum Moderators: phranque
1. Is there any disadvantage to have multiple files at /etc/apache2/conf.d/userdata/ (eg, "security.conf", "compress.conf", "mysqlinjection.conf", etc)? This would certainly make it easier for me to maintain any over time. I suspect that there's no disadvantage, other than maybe causing a restart to be a tad slower, but I wanted to make sure.
2. Assuming it's OK to have multiple files, can I control the order in which they are loaded?
Shell-style (fnmatch()) wildcard characters can be used in the filename or directory parts of the path to include several files at once, in alphabetical order.
but if there's a risk of a rule matching in the wrong section then I'll have to spend a lot more time reviewing everything.
3. Following that, can I use RewriteEngine on in one .conf, and then use rules in all of the other files without turning it on again?
you need to have a RewriteEngine on directive for each virtual host in which you wish to use rewrite rules.
if there's a risk of a rule matching in the wrong section then I'll have to spend a lot more time reviewing everythingPlease explain in a little more detail what you mean by “section”.
you need to have a RewriteEngine on directive for each virtual host in which you wish to use rewrite rules.
Please explain in a little more detail what you mean by “section”.
does that mean that each .conf fie in the same directory needs "RewriteEngine on"?
(eg, RewriteRule ^apple-touch-icon- /apple-touch-icon.png [L])
don’t forget to change any patterns that involve ^ since this behaves differently when not in a (directory context)
RewriteRule ^/apple-touch-icon- /apple-touch-icon.png [L]
i would carefully read and understand the [L] flag documentation:
If you are using RewriteRule in either .htaccess files or in <Directory> sections, it is important to have some understanding of how the rules are processed. The simplified form of this is that once the rules have been processed, the rewritten request is handed back to the URL parsing engine to do what it may with it.
## cPanel fix, exclude DCV checks from future RewriteRules
## note, cPanel plugs these lines in to EVERY RewriteRule >:-( so I'm trying to make that unnecessary
RewriteCond %{REQUEST_URI} ^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} ^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
# cPanel also includes these, but I exclude /.well-known below so they're not necessary
# RewriteCond %{REQUEST_URI} ^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
# RewriteCond %{REQUEST_URI} ^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$
# RewriteCond %{REQUEST_URI} ^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
# RewriteCond %{REQUEST_URI} ^/\.well-known/pki-validation/(?:\ Ballot169)?
RewriteRule ^ - [L]
## also exclude /.well-known, 403.php, 404.php
## should I totally exclude /.well-known? Or should I only worry about the 4 that cPanel defines?
RewriteRule ^\.well-known|40[34]\.php$ - [L]
Am I correct in understanding that this is NOT the case when I move it to the .CONF?
Should I use [END] to come to a screeching halt instead of [L]?
I'm specifically looking at these rules that I have at the top of my .htaccess but will be moving to .CONF
make sure your included .conf files aren't included from within a directory context.If you start the filepath with a / it shouldn't make any difference ... would it? (Happily, in this particular detail apache syntax seems to be identical to the familiar html linking syntax: if you start with / it means root--whether server or site--while if you don't, it becomes a relative link.)
make sure your included .conf files aren't included from within a directory context.If you start the filepath with a / it shouldn't make any difference ... would it? (Happily, in this particular detail apache syntax seems to be identical to the familiar html linking syntax: if you start with / it means root--whether server or site--while if you don't, it becomes a relative link.)