2
votes

I put WordPress' configuration into my VirtualHost directive, it looks like this:

<VirtualHost *:80>
ServerName www.example.com
ServerAlias example.com
DocumentRoot /var/www/html

<Directory />
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]
</Directory>
</VirtualHost>

When I put WordPress' configuration inside VirtualHost's root directory like above, the permalink and sub domain won't work.

But when I put WordPress' configuration inside the /etc/httpd/conf/httpd.conf root directory which is /var/www/html (as you can see it is the same root as Virtual host), then subdomain and permalinks are fine, I don't get it?

The reason I don't want to put WordPress' configuration in httpd.conf is because I want to make another site but it's not multisite, so I have to enter another WordPress' configuration on it.

  • I IncludeOptional the virtual host conf file at the very bottom of httpd.conf
  • I use CentOS 7
  • Apache 2.4
  • Wordpress 4.5.3
  • Mod rewrite included
1

1 Answers

2
votes

After few hours it seems another rewrite rule that came above the IncludeOptional path/to/virtualhost/*.conf in httpd.conf had interfere Wordpress' configuration.

To troubleshoot most common permalinks or subdomains problem in wordpress is always check your rewrite rules and make sure the Wordpress rule (that one for the .htaccess) is always on top of the others.