Question

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/mysite.com.conf 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 mysite.com.conf 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]
</IfModule>

# END WordPress

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

# END HTTPS Rewrite

Here is my current mysite.com.conf file:

<VirtualHost *:80>
    ServerAdmin webmaster@mysite.com
    DocumentRoot /var/www/mysite.com/html
    ServerName mysite.com
    ServerAlias www.mysite.com
    ErrorLog /var/www/mysite.com/logs/error.log
    CustomLog /var/www/mysite.com/logs/access.log combined
    <Directory /var/www/mysite.com/html/>
        AllowOverride All
    </Directory>
</VirtualHost>

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.

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.

Jarland

This comment has been deleted