WordPress on Django on Heroku

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.

Read More

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.

Related posts

Leave a Reply

1 comment

  1. I solved this by doing the following steps.

    1. Installed WordPress on a separate server (necessary since WP can’t run on the same server as your django app).

    2. Create a subdomain pointing to this installation using the domain control as follows http://blog.example.com/

    3. In views.py, I made the following view:

      def blog(request):
          return HttpResponseRedirect('http://blog.example.com/') 
      
    4. In urls.py, I added the following:

      url(r'^blog', views.blog, name='blog'))
      
    5. 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 as blog.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.