Using Apache .conf on a subdomain
I'm trying to move my .htaccess files to /etc/apache2/conf.d/userdata/ssl/2_4/[my username]/. I have a subdomain that I use for a sandbox, and I need a whole separate configuration for it.
Let's say that my account name is "example", the main domain is "example.com", and the subdomain is "ww2.example.com".
I'm using Apache version 2.4.46. I created a file at:
/etc/apache2/conf.d/userdata/ssl/2_4/example/ww2.example.com/01_config.conf
This was just a test run, so the file is very simple:
I uploaded this and rebooted Apache, but it doesn't work; I get a 404 error when I go to ww2.example.com/apple-touch-icon-foo.png, when I'm expecting to be redirected. Am I misunderstanding how I should have named the path? Or is there some other error that I'm overlooking? I should mention that I have set some server-wide files at /etc/apache2/conf.d/userdata/ that work fine, so it's not an issue of Include not working. Thanks!
RewriteEngine on
# I also tried ^/apple-touch-icon-
RewriteRule ^apple-touch-icon- /apple-touch-icon.png [L]I uploaded this and rebooted Apache, but it doesn't work; I get a 404 error when I go to ww2.example.com/apple-touch-icon-foo.png, when I'm expecting to be redirected. Am I misunderstanding how I should have named the path? Or is there some other error that I'm overlooking? I should mention that I have set some server-wide files at /etc/apache2/conf.d/userdata/ that work fine, so it's not an issue of Include not working. Thanks!
-
Hey there! Everything you've said sounds right to me. If your include file didn't exist you may need to rebuild Apache with the /scripts/rebuildhttpdconf script to ensure it's there, but you aren't doing anything obviously wrong from the steps you described. Can you try teh rebuild script and restarting to see if that helps get things working? 0 -
Good news! That worked :-) It's weird, when I uploaded server-wide files to /etc/apache2/conf.d/userdata/ I didn't have to rebuild, I just restarted Apache and they worked fine. Now I'm led to a second, similar question. I created the one subdomain of ww2, so now I have a directory at /home/example/ww2.example.com. But I have 60+ domains parked on top of example.com, so in cPanel I created a ww2 subdomain for each of them and set "Document root" to "/ww2.example.com". That has been working fine with using a .htaccess file. I thought that creating .CONF files at /etc/apache2/conf.d/userdata/ssl/2_4/example/ww2.example.com/01_config.conf would apply to all of the parked domains since that's the document root, but it doesn't; I had to manually copy them to /etc/apache2/conf.d/userdata/ssl/2_4/example/ww2.parked_1.com/01_config.conf to get them to work on ww2.parked.com It's obviously not very efficient to have to create 60 directories and copy the same files to each of them. Is there a better way to just have a single directory for all of them? 0 -
I'm glad the rebuild took care of the issue :D If I'm reading the second issue there correct, there's not really a better way. Each domain is going to need a separate include because of how Apache processes those files. It might be worth looking into creating a hook script of some sort that sets up the include file automatically, that gets called when you create the subdomain. While this thread is specific to an addon domain, it may get you pointed in the right direction: 0
Please sign in to leave a comment.
Comments
3 comments