Question

Pretty permalinks going to 404

I’ve been having this issue all day and I can’t figure it out. My site keeps going to a 404 page when it’s accessing the pretty url for a blog post

My htaccess file looks fine to me and so does the vhost conf file but maybe I’m missing something? I’ve restarted apache and also enabled a2enmod rewrite…

http conf

<VirtualHost *:80>
  ServerAdmin webmaster@domain.com
  ServerName domain.com
  ServerAlias www.domain.com

  DocumentRoot /var/www/domain.com
  <Directory />
       Options FollowSymLinks
       AllowOverride None
  </Directory>
  <Directory /var/www/domain.com>
       Options Indexes FollowSymLinks MultiViews
  AllowOverride None
       Order allow,deny
       allow from all
  </Directory>
  ErrorLog ${APACHE_LOG_DIR}/domain.com-error.log
  CustomLog ${APACHE_LOG_DIR}/domain.com-access.log combined

RewriteEngine on
RewriteCond %{SERVER_NAME} =domain.com [OR]
RewriteCond %{SERVER_NAME} =www.domain.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

https conf

<IfModule mod_ssl.c>
<VirtualHost *:443>
  ServerAdmin webmaster@domain.com
  ServerName domain.com
  ServerAlias www.domain.com

  DocumentRoot /var/www/domain.com
  <Directory />
       Options FollowSymLinks
       AllowOverride None
  </Directory>
  <Directory /var/www/domain.com>
       Options Indexes FollowSymLinks MultiViews
  AllowOverride None
       Order allow,deny
       allow from all
  </Directory>
  ErrorLog ${APACHE_LOG_DIR}/domain.com-error.log
  CustomLog ${APACHE_LOG_DIR}/domain.com-access.log combined

SSLCertificateFile /etc/letsencrypt/live/domain.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/domain.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>

.htaccess

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*\.php)$ $1 [L]
RewriteRule . index.php [L]

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

@hansen

I’ve changed the two conf files as you wrote and removed the .htaccess file. After, I went ahead and saved Plain and Post name in the permalinks settings. It doesn’t seem have created a new .htaccess file. It’s still doing a 404 on the pretty link blog post : \

Hi @tannerchung

Can you delete the .htaccess file. Then go to domain.com/wp-admin/options-permalink.php and select Plain, click save, then click Post name and click save.

Also edit you http conf and change it to this instead:

<VirtualHost *:80>
  ServerName domain.com
  ServerAlias www.domain.com
  Redirect / https://domain.com/
</VirtualHost>

And https conf to this:

<IfModule mod_ssl.c>
<VirtualHost *:443>
  ServerAdmin webmaster@domain.com
  ServerName domain.com
  ServerAlias www.domain.com

  SSLCertificateFile /etc/letsencrypt/live/domain.com/fullchain.pem
  SSLCertificateKeyFile /etc/letsencrypt/live/domain.com/privkey.pem
  Include /etc/letsencrypt/options-ssl-apache.conf

  DocumentRoot /var/www/domain.com

  ErrorLog ${APACHE_LOG_DIR}/domain.com-error.log
  CustomLog ${APACHE_LOG_DIR}/domain.com-access.log combined
</VirtualHost>
</IfModule>