0

My question is similar to How to do redirect the URL of site but I want to do the opposite. And there is a further challenge or two I cannot understand yet.

Our setup is a Magento 2.3.3 store running on a dedicated (not shared) Linux host. We have full root access and can edit all files as needed. The httpd server is Apache 2.4.41.

Upon advice received recently, we followed this procedure:

Modify docroot to improve security | Magento 2 Developer Documentation

Now the Magento site is served at https://www.example.com/ and it is working correctly. The Magento DocumentRoot is /var/www/html/magento2/pub/. All is good for that step. But we cannot reconcile that step with the next steps we need to accomplish.

We will be installing WordPress at /var/www/html/wordpress/. And we will have Question2Answer at /var/www/html/q2a/.

We need to accomplish the following:

I know about Apache Alias directives and reviewed this answer but the following approach does not meet our goals:

<IfModule alias_module>
    Alias /shop     /var/www/html/magento2/pub/
</IfModule>

While the URI https://www.example.com/shop works, the problem is that https://www.example.com also serves the Magento site. We want the WordPress blog to be served at https://www.example.com.

How can we accomplish our goal with Magento and our two other virtual hosts (all at the same domain www.example.com)?

All pages are served via HTTPS exclusively using a Let's Encrypt certificate. Here are the current virtual host files (only Magento is installed so far).

<VirtualHost *:80>
        ServerAdmin webmaster@example.com
        DocumentRoot "/var/www/html/magento2/pub/"
        ServerName www.example.com
        Redirect permanent / https://www.example.com
</VirtualHost>

<IfModule alias_module>
        Alias /shop     /var/www/html/magento2/pub
</IfModule>

<Directory "/var/www/html/magento2/pub/">
        AllowOverRide None
        Include /var/www/html/magento2/pub/.htaccess
</directory>

<Directory "/var/www/html/magento2/pub/errors">
        AllowOverRide None
        Include /var/www/html/magento2/pub/errors/.htaccess
</directory>

<Directory "/var/www/html/magento2/pub/media">
        AllowOverRide None
        Include /var/www/html/magento2/pub/media/.htaccess
</directory>

<Directory "/var/www/html/magento2/pub/media/customer">
        AllowOverRide None
        Include /var/www/html/magento2/pub/media/customer/.htaccess
</directory>

<Directory "/var/www/html/magento2/pub/media/downloadable">
        AllowOverRide None
        Include /var/www/html/magento2/pub/media/downloadable/.htaccess
</directory>

<Directory "/var/www/html/magento2/pub/media/import">
        AllowOverRide None
        Include /var/www/html/magento2/pub/media/import/.htaccess
</directory>

<Directory "/var/www/html/magento2/pub/media/theme_customization">
        AllowOverRide None
        Include /var/www/html/magento2/pub/media/theme_customization/.htaccess
</directory>

<Directory "/var/www/html/magento2/pub/static">
        AllowOverRide None
        Include /var/www/html/magento2/pub/static/.htaccess
</directory>

And for HTTPS:

<IfModule mod_ssl.c>
<VirtualHost *:443>
    ServerAdmin webmaster@example.com
    DocumentRoot "/var/www/html/magento2/pub/"
    ServerName example.com
    ServerAlias www.example.com

    SSLCertificateFile /etc/letsencrypt/live/www.example.com/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/www.example.com/privkey.pem
    Include /etc/letsencrypt/options-ssl-apache.conf
    SSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1
    SSLCipherSuite HIGH:!aNULL:!MD5:!3DES:!CAMELLIA:!AES128
</VirtualHost>
</IfModule>
-1

I would start looking for a single solution only with magento 2, using the magento 2 extensions for blog and questions.

unless you have some crazy idea to maintain and design all this separately.

this will speedup development and you will have only one framework to follow updates.

make it simple. users dont care about your backend, and developer will thank you.

3
  • WordPress is much more feature-rich and widely supported with plugins compared to Magento blogging extensions. I can possibly eliminate Question2Answer. However, you are really answering a different question than the one I asked. I would still like to know how to solve the Apache redirect/rewrite/alias/whatever issue that I asked about. Thank you for your replies! – MountainX Dec 5 '19 at 5:06
  • to cook 3 eggs you need only one pan, not 3 :) I like to look at customer decisions that look like NASA space program... what for?? – MagenX Dec 5 '19 at 11:28
  • @MageX - that's you opinion, and I'm sure it works for you. But it has nothing to do with answering this particular question. I want to know how to do a specific thing with Apache virtual host files. Can you answer that or not? – MountainX Dec 5 '19 at 23:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.