Name-based virtual host configuration in Apache seems to cause a “500 Internal Server Error”

it opens the site in the domain

Have you tested inner pages, not just the homepage?

A seeming inconsistency in your config is that you have defined DocumentRoot /var/www/html/10_sites/ in your vHost(s) yet you have set RewriteBase /10_sites/ in your .htaccess file.

Unless your site files are located in /var/www/html/10_sites/10_sites/ (yes, the last directory repeated twice) then you will get a rewrite-loop (500 Internal Server Error) for any requests other than the homepage (including /wp-admin pages), since index.php will not be found.

Requests for the homepage, ie. http://example.com/, will work OK since this does not rely on the mod_rewrite directives in .htaccess to route the request to index.php. Instead, this is handled by mod_dir and the DirectoryIndex.

I did it and it was as follows for each site:

However, there are other inconsistencies with your config…

If you are using WordPress multisite (as implied by your .htaccess file) then you should not be defining a vHost for each domain (at least there is no need to unless you specifically need separate log files from the get go*1 or to perhaps customise the config per domain – neither of which is suggested by your config). You would simply include a ServerAlias for each domain. (There is no need to define ServerName and ServerAlias the same – as implied by your config.)

(*1 The config you posted implies you are using a single access and error log for all domains. This is more performant than using separate log files for each domain, however, you need to customise the log format to include the requested hostname (which you have not done). Otherwise, you will not be able to split the logs later.)

But if you are not using WP multisite then you shouldn’t be defining the same vHost for each domain (as implied by your <VirtualHost> config).

Leave a Comment