SetEnvIf Host code in Apache htaccess.conf cauing Apache to not start

Keywords: Magento - Virtual Machines - Technical issue - Services (Apache, MariaDB, MySQL…)

bnsupport ID: 571c1ffc-934e-fe26-e3a2-d1733b83d26f

bndiagnostic output:

? Apache: Found possible issues
https://docs.bitnami.com/general/apps/wordpress/troubleshooting/debug-errors-apache/
https://docs.bitnami.com/bch/apps/moodle/troubleshooting/deny-connections-bots-apache/

bndiagnostic failure reason: The suggested guides are not related with my issue

Description:
Hi,

I am using the below code in to load multiple websites in Magento by adding the information in the below file in Apache.

magento-htaccess.conf

Everything works perfectly except when I add a specific website name. Every other name works (Apache starts and re-directs to the correct store)

SetEnvIf Host www\notworking.domain\.com MAGE_RUN_CODE=notworking
SetEnvIf Host www\notworking.domain\.com MAGE_RUN_TYPE=website
SetEnvIf Host ^notworking.domain\.com MAGE_RUN_CODE=notworking
SetEnvIf Host ^notworking.domain\.com MAGE_RUN_TYPE=website

With this particular store, when I was originally creating the theme, I miss-spelt the directory name which I have since changed. Since then, even if I remove the website/store/store view and re-create using the same name, and put in the SetEnvIf Host code above using this name, Apache will not start. If I remove it, Apache starts and works as expected. If I add the above code with a different sub-domain, everything works as well. It seems Apache does not like this particular name, and will not start if I add it to the magento-htaccess.conf

Is there somewhere I can look to trouble-shoot this? I would like to use this particular sub-domain.

Hi @isaacabides,

Thanks for using Bitnami. We have a guide for configuring multiple sites for Magento, but the configuration suggested doesn’t mention the file you are editing here (magento-htaccess.conf). Can you check our guide in case you missed any step?

https://docs.bitnami.com/general/apps/magento/configuration/enable-multisite/

Thanks for the reply. I did use the guide and it actually works perfectly for me except for this one particular sub domain that I am trying to add. If I create a different sub domain with a different name, it will work as expected. For some reason, this particular name will cause Apache to not start, even if I reboot the VM.

I am editing a file “magento-htaccess.conf” that I created, in the /opt/bitnami/apache/conf/vhosts/htaccess dir. It is references in the “magento-vhost.conf” file at /opt/bitnami/apache/conf/vhosts

Since this method works (I have 4 other sub domains, and have since added more with other names), It leads me to believe that it is something specific to do with the name and how I created it. I have tried, removing the website/store/store view and re-creating but to no avail. I will try again and also remove the theme associated with the website.

Hi @isaacabides,

Thanks for the information. The magento-htaccess.conf file is not retrieved by the bnsupport tool, can you share it with us? you can use the next snippet here in the forum, that will show the code in a more convenient way

```
your file content
```

and this is the resulting format

your file content

Hi,

The information in magento-htaccess.conf (which I created) is the exact same as what I posted above except I have changed the name(s) of the sub domains I am using for privacy. Upon doing more testing, it looks like I cannot use any sub domain that starts with the letter “p” If I do, Apache will not restart or start. If for instance, I change to the letter “q” in magento-htaccess.conf, Apache starts and everything works as expected.

SetEnvIf Host www\p.domain\.com MAGE_RUN_CODE=p
SetEnvIf Host www\p.domain\.com MAGE_RUN_TYPE=website
SetEnvIf Host ^p.domain\.com MAGE_RUN_CODE=p
SetEnvIf Host ^p.domain\.com MAGE_RUN_TYPE=website

Just having the above code (nothing else) in magento-htaccess.conf will prevent Apache from starting. Changing the “p” to anything else will work.

Hi @isaacabides,

Thanks for your message. Can you share with us the content of the file privately? I think there is a typo in the configuration for this subdomain, and I’d like to take a look at the entire file just in case I see something relevant for this case.

What I think, taking a look at our docs and the config you shared, may be causing your issues, is that you are scaping the p caracter in your domain, which is wrong. I mean that the domain definition in the next line

SetEnvIf Host www\p.domain\.com MAGE_RUN_CODE=p

will be internally used in Apache as wwwpdomain.com, instead of www.p.domain.com what I understand it is what you are expecting to get. Can you try defining the new domain using the next lines? Notice I’m just escaping all dots (plus adding another one after the www prefix)

SetEnvIf Host www\.p\.domain\.com MAGE_RUN_CODE=p
SetEnvIf Host www\.p\.domain\.com MAGE_RUN_TYPE=website
SetEnvIf Host ^p\.domain\.com MAGE_RUN_CODE=p
SetEnvIf Host ^p\.domain\.com MAGE_RUN_TYPE=website

In addition, in our docs we mention this

Here, MAGE_RUN_CODE is the code provided when configuring the New Website.

Can you also double-check MAGE_RUN_CODE=p in your configuration is ok?

Hi,

Your the man! :slight_smile: Your new code works. Adding the “.” before the sub domain is the correct format.

Thanks again!

Hi @isaacabides,

Thanks for the info. I’m glad you fixed your issue! We will close this thread as solved. Please do not hesitate to open a new one with any other questions you may have.