Permalinks are not working in wordpress.

I have looked at all the similar questions, and I am still not able to get permalinks to work. I have confirmed that .htaccess is being accessed. I have also confirmed that mod_rewrite is enabled, and working, and even working in .htaccess. I will explain how I have tested this.

When things first weren’t working, I removed the rewrite rule in my /etc/apache2/sites-available/ and confirmed that I was able to get the site to load without https. I then inserted a bad line at the top of my .htaccess file, and it gave me a 500 error. I then removed that line, and added the rewrite rules that were originally in my file to the .htaccess file, and I inserted it between <IfModule mod_rewrite.c></IfModule> tags and tested it. I was redirected to the secure site. I am able to go to the page if I leave the default permalinks alone, but when I change them to anything besides “plain”, I get a 404 error.

Here is my .htaccess file as it sits now. The wordpress rules don’t work, but the HTTPS rules do.

# BEGIN WordPress
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]

# END WordPress

# HTTPS Rewrite
<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{SERVER_NAME} [OR]
    RewriteCond %{SERVER_NAME}
    RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

# END HTTPS Rewrite

Here is my current file:

<VirtualHost *:80>
    DocumentRoot /var/www/
    ErrorLog /var/www/
    CustomLog /var/www/ combined
    <Directory /var/www/>
        AllowOverride All

sudo a2enmod rewrite tells me “Module rewrite already enabled”

For additional information, I followed How To Install WordPress with LAMP on Ubuntu 18.04. I also followed all the prerequisites, including initial server setup, install a lamp stack, and letsencrypt guide for apache. I even rebuilt the server and started from scratch when it wasn’t working.

Needless to say, I am a bit perplexed. Any help would be appreciated.

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

DigitalOcean Employee
DigitalOcean Employee badge
August 27, 2018
Accepted Answer

Hello friend!

Check in /etc/apache2/apache2.conf and look for a <Directory> statement referring to /var/www. I’ll bet it has AllowOverride disabled. Try changing that to All, restart Apache, and see if it works.


DigitalOcean Employee
DigitalOcean Employee badge
August 27, 2018

This comment has been deleted

    Try DigitalOcean for free

    Click below to sign up and get $200 of credit to try our products over 60 days!

    Sign up

    Featured on Community

    Get our biweekly newsletter

    Sign up for Infrastructure as a Newsletter.

    Hollie's Hub for Good

    Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

    Become a contributor

    Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

    Welcome to the developer cloud

    DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

    Learn more
    DigitalOcean Cloud Control Panel