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]
  3. Restart Apache and you’re good to go.

Leave a reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

This site uses Akismet to reduce spam. Learn how your comment data is processed.