As the title says, when I change my permalinks in the admin, all my pages return a 404 (except homepage). I have to inlclude index.php
as the start of all the different paths. The paths all work fine, if I include index.php
.
For example:
Custom structure: /index.php/%postname%/%day%/
will work as I navigate my site.
Custom structure: /%postname%/%day%/
will not work (except homepage).
mod_rewrite is enabled on the server:
$ sudo a2enmod rewrite
Module rewrite already enabled
I have a .htaccess
file:
$cat /var/www/directory_name/.htaccess
# BEGIN WordPress
# The directives (lines) between `BEGIN WordPress` and `END WordPress` are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<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
...and it is writeable by the web server:
$ ls -al
-rwxr-xr-x 1 www-data www-data 461 Dec 3 14:11 .htaccess
My apache config:
$ cat /etc/apache2/sites-enabled/domain.conf
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName mydomain.com
ServerAlias www.mydomain.com
DocumentRoot /var/www/domain
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/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]
<Directory /var/www/domain/>
AllowOverride All
Options +FollowSymLinks
Require all granted
</Directory>
</VirtualHost>
$cat /etc/apache2/sites-enabled/domain-ssl.conf
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerAdmin webmaster@localhost
ServerName domain.com
ServerAlias www.domain.com
DocumentRoot /var/www/domain
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/domain.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/domain.com/privkey.pem
</VirtualHost>
</IfModule>
.htaccess
file in the document root with the appropriate mod_rewrite directives? If you do, remove the<IfModule>
wrapper - do you get an error? IF no error, add some nonsense to the start of the file - do you get an error now?<IfModule>
wrapper does not produce any noticeable difference when refreshing. Adding junk doesn't do anything either. Also, my.htaccess
is writeable by the web server.