We use Heroku to deploy our Wordpress project. However, everytime we push up it seems that all of the links bring the user to an Internal Server Error page. The homepage works.

Updating the permalinks (using the pretty permalinks for %postname%) solves this issue.

What we believe to be happening is that when a user hits: www.example.com/menu the permalinks haven't been updated yet, so the user sees an Internal Server Error. If you go to www.example.com/?p=2 you get redirected to www.example.com/menu but the page shows an Internal Server Error again.

Right now we have to update the permalinks every time we push up a new version of the site.

Anyone else have this problem and what did you do to solve it?

Much appreciation.

  • If you are pushing content then every time you change domains you have to change the permalinks for embedded links. Is that what you are doing? – s_ha_dum May 30 '13 at 15:34
  • Yes, I am pushing from my local machine up to Heroku's server. The links are correct (i.e. it goes to the correct page) but the pages just show an Internal Server Error. However, the .htaccess file isn't changing after I update the permalinks. So, not sure what updating permalinks actually does to solve the issue. – Brian Weinreich May 30 '13 at 15:39
  • 1
    Updating the permalinks causes the internal rewrite rules to be re-parsed. Look up wp_rewrite or var_dump($wp_rewrite); to get a good look at those rules. – s_ha_dum May 30 '13 at 15:55

The problem ended up being that the wp_rewrite was not flushed on the push to the Heroku server. So, what I ended up doing was creating a file in the root directory with the following code:

    global $wp_rewrite;

Then I added a deploy hook for heroku via command line

heroku addons:add deployhooks:http --url=http://example.com/reset_permalinks.php

So, now when I deploy my application on the Heroku server, it runs the flush_rules() method and all is good. Thanks s_ha_dum!


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.