Reconfiguring Apache to serve website root from new php source and specific sub-urls from old django site

后端 未结 1 841
Happy的楠姐
Happy的楠姐 2021-01-27 00:45

How do I make a django website (in a apache/mod_wsgi/django setup) which is configured to serve from the root url, serve only for specific sub-url but not the root url? The root

相关标签:
1条回答
  • 2021-01-27 01:06

    Props to Graham Dumpleton. He answered another question of the exact same kind in this Q&A: Django (wsgi) and Wordpress coexisting in Apache virtualhost.

    In short, after configuring Apache so the root url is served from php, the solution to route specific sub urls to django, but making it think its mount point is still the root, is WSGIScriptAliasMatch. To this (example)problem the simple addition to the apache virtual host config was this:

    WSGIScriptAliasMatch ^(/(shop|news)) /opt/mysite/mysite.wsgi$1
    

    The whole virtual host config for this example is:

    <VirtualHost *:80>
        ServerAdmin admin@mysite.com
        ServerName mysite.com
    
        # mappings to django
        WSGIScriptAliasMatch ^(/(shop|news)) /opt/mysite/mysite.wsgi$1
        <Directory /opt/mysite>
            Order allow,deny
            Allow from all
        </Directory>
    
        # mappings to wordpress 
        DocumentRoot /var/www/mysiteWP/
        <Location "/var/www/mysiteWP/">
                Options -Indexes
        </Location>
    </VirtualHost>
    
    0 讨论(0)
提交回复
热议问题