I have a running CentOS 7 with Apache 2 mariadb stack with vhosts and Let's Encrypt. I've installed WordPress 4.9.6 on a virtual host using debian style (sites-available -> sites-enabled).
My problem is that I cannot use permalinks. I copy my server configuration below.
getenforce
Disabled
/etc/httpd/sites-available/example.conf
:
<VirtualHost *:80>
ServerName www.example
ServerAlias example
DocumentRoot /var/www/example/public_html
ErrorLog /var/www/example/error.log
CustomLog /var/www/example/requests.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =example [OR]
RewriteCond %{SERVER_NAME} =www.example
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
/etc/httpd/sites-available/example-le-ssl.conf
:
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName www.example
ServerAlias example
DocumentRoot /var/www/example/public_html
ErrorLog /var/www/example/error.log
CustomLog /var/www/example/requests.log combined
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/example/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/example/chain.pem
</VirtualHost>
</IfModule>
Apache configuration file /etc/httpd/conf/httpd.conf
:
<Directory />
AllowOverride none
Require all denied
</Directory>
DocumentRoot "/var/www/html"
<Directory "/var/www">
AllowOverride None
Require all granted
</Directory>
<Directory "/var/www/html">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
Config. file on the public_html directory /var/www/example/public_html/.htaccess
:
# 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
I've enable permalinks settings on WordPress admin:
/%postname%/
Permissions of .htaccess
file are:
-rw-r--r-- 1 apache apache 235 Jun 24 13:54 .htaccess
sudo httpd -M
shows:
(..)
rewrite_module (shared)
(..)
I have a running CentOS 7 with Apache 2 mariadb stack with vhosts and Let's Encrypt. I've installed WordPress 4.9.6 on a virtual host using debian style (sites-available -> sites-enabled).
My problem is that I cannot use permalinks. I copy my server configuration below.
getenforce
Disabled
/etc/httpd/sites-available/example.conf
:
<VirtualHost *:80>
ServerName www.example
ServerAlias example
DocumentRoot /var/www/example/public_html
ErrorLog /var/www/example/error.log
CustomLog /var/www/example/requests.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =example [OR]
RewriteCond %{SERVER_NAME} =www.example
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
/etc/httpd/sites-available/example-le-ssl.conf
:
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName www.example
ServerAlias example
DocumentRoot /var/www/example/public_html
ErrorLog /var/www/example/error.log
CustomLog /var/www/example/requests.log combined
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/example/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/example/chain.pem
</VirtualHost>
</IfModule>
Apache configuration file /etc/httpd/conf/httpd.conf
:
<Directory />
AllowOverride none
Require all denied
</Directory>
DocumentRoot "/var/www/html"
<Directory "/var/www">
AllowOverride None
Require all granted
</Directory>
<Directory "/var/www/html">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
Config. file on the public_html directory /var/www/example/public_html/.htaccess
:
# 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
I've enable permalinks settings on WordPress admin:
https://example/%postname%/
Permissions of .htaccess
file are:
-rw-r--r-- 1 apache apache 235 Jun 24 13:54 .htaccess
sudo httpd -M
shows:
(..)
rewrite_module (shared)
(..)
For the next person, be sure to set AllowOverride All in the correct directory. In Damon's case he set AllowOverride All in the /var/www/html directory, but his site is located in /var/www/example/public_html. I could be wrong, but the AllowOverride setting is specific to the directory. Damon should add the AllowOverride All setting to the /etc/httpd/sites-available/example.conf and /etc/httpd/sites-available/example-le-ssl.conf files. Without this setting the .htaccess file wordpress uses will work.