dhruve
By:
dhruve

Wordpress Permalinks not working on Ubuntu 14.04

September 24, 2014 35.5k views

I have followed this guide, and everything worked correctly except that I cannot change the Wordpress permalink setting. I have followed the guide, and other solutions to questions here, but none are working for some reason.
On WP, when I change the permalinks, and go to the original domain.com/?p=123, it changes the url to the correct domain.com/month/day/post-title, however it takes me to the apache 404 page then.

Any help is appreciated.

1 comment
  • To clarify, the problem in this scenario is that .htaccess is not enabled. To fix that, you add AllowOverride All for your site's directory. In my case, I did that in apache.conf.

4 Answers

I had this issue with pretty permalinks myself, and the solution was to edit my vhosts conf file for that site. Here's what worked for me:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName broseph.com.au

    DocumentRoot /var/www/broseph.com.au/public_html
    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>
    <Directory /var/www/broseph.com.au/public_html>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>
  • Also make sure your .htaccess file has the proper permissions for WP to write to it. You'll see an error if it doesn't.
  • FYI: conf files are in /etc/apache2/sites-available
  • Don't forget to restart apache after editing the conf file: sudo service apache2 restart
  • Thank You so much.

  • Glad it worked out. :)

  • I'm having the same problem.

    I think this is exactly what I need to fix it but I can't seem to get it to work.

    In /etc/apache2/sites-available I have two files. default-ssl.conf and 000-default.conf.

    I added...

    <Directory />
            Options FollowSymLinks
            AllowOverride None
        </Directory>
        <Directory /var/www/broseph.com.au/public_html>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all
        </Directory>
    

    to both files and changed the Directory (mine is var/www/html). restarted apache. Didn't work.

    I've tried changing the ServerAdmin to root and the ServerName to both the ip as well as the url of the site. Restarting apache every time.

    What Am I missing?

  • Did you change this...

     /var/www/broseph.com.au/public_html
    

    ... to the proper path of your public_html directory?

  • I did. I found my solution here...

  • Thanks @tlhaas that worked

  • I find my solution here too.
    Tks @thauvette !

  • I instaled wordpress manually on myipaddress/blog .

    If i set permalinks with post name they were not working. it is showing a 404 page.

    please help me with this?

My issue was from making the update from Ubuntu 12.04 to 14.04 was that my apache2.conf was not correct configured:

In terminal type:

sudo gedit /etc/apache2/apache2.conf

Find:

<Directory /var/www/>

And make sure the AllowOverride directive is set to All.

After I made that change I could use custom permalink structures in Wordpess again, hope this helps anyone as it did me!

I was having a similar issue. The website would work on the home page and I could log into WordPress admin, but if I clicked on any other link it resulted in a 404 error.

The page that is linked to in some of the other answers isn't the ideal solution. Basically, it turns on AllowOverride to "All" which allows .htaccess files to work. This is great when you are on shared hosting with no access to the apache configuration file, but shouldn't be used when you are on a host such as digitalocean, where you have access to the server configuration file.

The ideal solution is to put the information that is in the WordPress .htaccess file into the main apache configuration file. This helps to improve the server performance. This page shows how to do it and why: http://haydenjames.io/disable-htaccess-wordpress-performance/

Have another answer? Share your knowledge.