Subdomain route to subfolder with htaccess on wordpress Subdomain route to subfolder with htaccess on wordpress wordpress wordpress

Subdomain route to subfolder with htaccess on wordpress


You have to create a virtual host in apache config.

<VirtualHost *:80>    ServerName sub.domain.com    DocumentRoot /var/www/sub</VirtualHost>

Or VirtualDocumentRoot if mod_vhosts_alias is enabled.

<VirtualHost *:80>    ServerName sub.domain.com    ServerAlias *.domain.com    VirtualDocumentRoot /var/www/%1</VirtualHost>

In above I am pointing it to /sub directory if it exists. After all changes restart the server.


You can add below line of code in your wp-config.php files

define('WP_HOME','http://sub.domain.com');define('WP_SITEURL','http://sub.domain.com');