virtualhost tagged posts

Apache Virtualhost to WordPress Permalinks

WordPress Permalinks create RESTful link style like: blog/category/sub-cat/post-title. These are not actual directories in your Apache DirectoryRoot hence you cannot just set a subdomain to point to a WP Permalinks via DocumentRoot /var/www/category/blog/bla/bla/bla.

In my case I was trying to set security.addaxsoft.com to point to addaxsoft.com/blog/security. Many methods failed and the only trick that worked resides in RewriteRules and WordPress URL Parameters.

  1. Set new DNS A record. eg: security.addaxsoft.com some-IP-address
  2. Set new VirtualHost in your apache config file as follow:
    <VirtualHost *:80>
    ServerName security.addaxsoft.com
    DocumentRoot /var/www/
    RewriteEngine On
    RewriteRule . /var/www/index.php?category_name=[YOUR CATEGORY NAME]
    </VirtualHost>
  3. Restart Apache and you’re good...
Read More