msomers
By:
msomers

WordPress Permalinks Broken

April 9, 2013 24.7k views
I followed the guide on installing Wordpress on Ubuntu 12. Everything is working fine, except for when I change my permalink structure to Month/Post Name. The main blog page works, but post links throw a 404 error. I tried a few things: - Enabled mod_rewrite with a2enmod rewrite and restarted Apache - Set permissions to .htaccess to 777 so Wordpress could update the file as needed when I updated the Permalink settings. Is there something else I'm missing here to get this working?
2 comments
  • I am having problems. When I open the /etc/apache2/sites-available/default file in the console - it is a blank screen? this is a brand new droplet

  • Anyone find a solution to this?

    I just followed all the instructions and when I pull up my Wordpress site that is now on the DO droplet, I get the main page and even can go to Dashboard, but many of my pages and links are PAGE NOT FOUND!

    I've tried the Permalinks resetting tips of saving the format again, but that doesn't help.

    I've even made sure my .htaccess file still have the following:

    BEGIN WordPress

    RewriteEngine On
    RewriteBase /
    RewriteRule ^index.php$ - [L]
    RewriteCond %{REQUESTFILENAME} !-f
    RewriteCond %{REQUEST
    FILENAME} !-d
    RewriteRule . /index.php [L]

    END WordPress

    No change.

    What am I missing?

16 Answers

Permalink Problem

Inside of this file, we want to change all things.

sudo nano /etc/apache2/sites-available/000-default.conf

000-default.conf - should look something like this:

<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html

        <Directory /var/www/html/>
            Options Indexes FollowSymLinks
            AllowOverride All
            Require all granted
        </Directory>

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

When you are finished, save and close the file.

Next, we need to enable the rewrite module, which allows you to modify URLs. You can do this by typing:

sudo a2enmod rewrite

After you have made these changes, restart Apache:

sudo service apache2 restart
If you've followed the initial steps and you've not been able to get rewrite to work for you, do the following :::

Firstly it's important you restart the apache2 server without any errors, ( Restarting web server apache2 : error ... ) ::: If you do get this error do the folllowing :::

1) sudo nano /etc/apache2/httpd.conf
2) Add, ServerName localhost


Open up the following file, and replace every occurrence of "AllowOverride None" with "AllowOverride all"

1) sudo nano /etc/apache2/sites-available/default
2) sudo service apache2 restart
There is a discussion of this here:

https://www.digitalocean.com/community/questions/ubuntu-12-04-lamp-wordpress-htaccess-errors

Thanks Etel - I've tried all that's recommended in that thread to no success. I will also respond to that thread.
@Michael's solution of adding "AllowOverride all" worked for me. (Note: "all" should be in lower-case)

I listed all the steps it took to get this working for me below:

http://randomwordpresstips.wordpress.com/2013/05/10/enabling-permalinks-on-wordpress-install-ubuntu-12-10/

P.S:
only comment on michael's reply : There is no httpd.conf in ubuntu's apache2. My server restart kept complaining the below error but it did not affect permalinks or my blog

error:
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
That is just a warning, you can ignore it - it won't affect anything.
@narenlog On that system the configuration files are in `apache2.conf` rather than `httpd.conf`. Add the `ServerName localhost` line to that file and you'll get the desired result.
this work for me
http://randomwordpresstips.wordpress.com/2013/05/10/enabling-permalinks-on-wordpress-install-ubuntu-12-10/

thanks
Answer by Michael worked, Thank you.
But if I try to log in to WordPress (/wp-admin) it redirects to IP instead of using domain.com/wp-amdin it uses 111.111.111.11/wp-amdin
@abachuk: Are you still experiencing this issue?
I had to define site_url in wp-config. It fixed the issue. Thanks
This helped me because of running my wordpress installation in virtual hosts and not in the root:

http://wordpress.stackexchange.com/questions/46437/rewrite-rules-not-working-on-a-vhost-everything-goes-to-index-php
How do you fix this issue in CentOS 6/nginx?

Hi -

I'm having trouble getting permalinks to work on my wordpress site. These are my droplet details: 512MB Ram, 20GB SSD Disk, Ubuntu 14.04 x64.

I'm following the steps listed here: https://randomwordpresstips.wordpress.com/2013/05/10/enabling-permalinks-on-wordpress-install-ubuntu-12-10/

These are the steps I followed (restated, more or less):

1) Enabled mod_rewrite using this command:
sudo a2enmod rewrite

2) Restarted the apache server using this command:
service apache2 restart”

3) Updated the .htaccess file in my Wordpress site's web directory (in my case: /var/www/html) to the following:

BEGIN WordPress

RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ – [L]
RewriteCond %{REQUESTFILENAME} !-f
RewriteCond %{REQUEST
FILENAME} !-d
RewriteRule . /index.php [L]

END WordPress

4) Changed the permissions on the .htaccess file to 666 using my FTP software (Filezilla in my case).

This is where I get stuck. The instructions go on to say:

"Open up the following file, and replace every occurrence of “AllowOverride None” with “AllowOverride all” (note : “all” should be in lower-case for this to work)

1) sudo nano /etc/apache2/sites-available/default
2) sudo service apache2 restart"

I found my way to this location: /etc/apache2/sites-available. In that folder I see two files:
000-default.conf
default-ssl.conf

I checked out both of those files but I don't see "AllowOverride" anywhere.

When I try changing the setting on the site I still have the same 404 problem.

  • You'll want to modify 000-default.conf adding this below the document root line.

       <Directory /var/www/location-to-blog>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride all
                Order allow,deny
                allow from all
        </Directory>
    

    Don't forget to service apache2 restart

    Dave.

Im having an odd issue with this, that on google I find was relevant, and the fixes work, from wordpress 2.5 (im on 4.3)

Permalinks work, if I make the structure "/index.php/%postname%"
Anything else.... doesnt work.
Any ideas ?????? :)

Have another answer? Share your knowledge.