I’m not sure if this is entirely solvable. Nevertheless, here’s the problem I’m facing.
I’ve created a Django app deployed on heroku and then added a custom domain to the herokuapp.
This domain has it’s own hosting somewhere else where a wordpress installation has been setup in a folder /blog
. So the url to the blog in reality is domain.com/blog
. However, after configuring the DNS to point to appname.herokuapp.com
, the /blog
url is understandably not working.
What should I do to fix this? Or is there a better solution, as the blog is quite an important part of the web app.
I solved this by doing the following steps.
Installed WordPress on a separate server (necessary since WP can’t run on the same server as your django app).
Create a subdomain pointing to this installation using the domain control as follows
http://blog.example.com/
In
views.py
, I made the following view:In
urls.py
, I added the following:Your next problem is going to be that once the WP domain is hit, it’ll have no static assets(CSS/JS/images). This is because they are static pointing to
example.com/blog/wp-content
. To solve this, you’ll need to add an A name record for the assets asblog.example.com/wp-content
(Can’t properly remember what the exact A name record was, but it is something on these lines)It’s a little convoluted but it works.