Reputation: 2249
I have a Django based site served by Apache2. My virtualhost is configured so that my domain (call it example.com) serves my wsgi application.
I would also like to serve a Wordpress site at example.com/blog using Apache. How would I serve the Wordpress site at /blog using Apache? Currently, my request gets captured by Django and I get a 404 since /blog is not in my Django urls.
Upvotes: 0
Views: 303
Reputation: 42
In the Django docs (https://docs.djangoproject.com/en/1.9/howto/deployment/wsgi/modwsgi/) they give this example:
Alias /media/ /path/to/mysite.com/media/
Alias /static/ /path/to/mysite.com/static/
<Directory /path/to/mysite.com/static>
Require all granted
</Directory>
<Directory /path/to/mysite.com/media>
Require all granted
</Directory>
WSGIScriptAlias / /path/to/mysite.com/mysite/wsgi.py
<Directory /path/to/mysite.com/mysite>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
This is for static files, but would work for your blog too.
Upvotes: 2
Reputation: 2249
In your Apache conf add these lines to your VirtualHost:
Alias /blog /var/www/example.com/blog/
<Directory /var/www/example.com/blog>
Require all granted
</Directory>
Upvotes: 0
Reputation: 17713
Your problem is that you don't recognize the blog reference until you are in the Django URL router. Although you can do a URL-rule + view to do a redirect, the easiest way to do this is create a new subdomain, e.g. blog.mydomain.com, and configure Apache to handle the additional site. I do this for all of my Django sites and it works fine.
Upvotes: 0