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.
Fonte: https://www.digitalocean.com/community/questions/permalinks-are-not-working-in-wordpress