-1

Just for assumption here

testsite.com which is my php application and

testsite.com/project is python application

I have following settings in my apache site config file /etc/apache2/sites-available/site.conf

<VirtualHost *:443>
                ServerAdmin webmaster@testsite.com

                DocumentRoot /var/www/html

                ErrorLog ${APACHE_LOG_DIR}/error.log
                CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

<VirtualHost *:443>
                ServerAdmin webmaster@testsite.com

                DocumentRoot /var/www/html/test-project

                <Directory /var/www/html/test-project/test-project>
                    <Files wsgi.py>
                        Require all granted
                    </Files>
                </Directory>
                WSGIDaemonProcess test python-path=/var/www/html/test-project/test-project python-home=/var/www/html/test-project
                WSGIProcessGroup test
                WSGIScriptAlias / /var/www/html/test-project/test-project/wsgi.py

                ErrorLog ${APACHE_LOG_DIR}/error.log
                CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Looking at above config, I just want any url with testsite.com/ will get served from first virtualhost which is my php application and its working and whenever only this specific testsite.com/project url hits then it should get served from second virtualhost which is my python application.

So inorder to get this url testsite.com/project served from second virtualhost it has to get bypass from first virtualhost. Please suggest how do I do that ? What should I do in first virtualhost so that it wil get bypassed to second.

NOTE: This is not related with url rewriting so please do not suggest anything rewriting rule or anything regarding that.

1 Answers1

0

Virtualhost is always tied to a domain name. You cannot have two VirtualHost entries that point to the same domain and different paths there.

You need to move both your PHP and Python application to a single VirtualHost, which handles your domain.

Tero Kilkanen
  • 34,499
  • 3
  • 38
  • 58
  • I tried it under one virtualhost but it only works for ```DocumentRoot``` we have given. And I need separate document root for individual applications to be served. since for my python application to be served I need ```WSGIScriptAlias``` allocated to ```/``` so that all urls under python application should get served properly. Please suggest if you have any solution for the same – Sunny Chaudhari Apr 03 '21 at 07:39