How to map sub domain to sub folder | Ubuntu Apache-2 Server | WordPress

Опубликовано: 30 Апрель 2026
на канале: Ankit Wasankar
10,618
114

Complete tutorial at : https://tutorials.webencyclop.com/blo...
---------------------------------------------------------------------
This video will demonstrate how to map a subdomain to a subfolder on the server without using the .htaccess file. Here we are using Apache 2 Server virtual host configuration for subdomain mapping.
For this demonstration to work on your server, you will require sudo access, so that commands can be executed as an administrator.
---------------------------------------------------------------------------------------------
The server is Apache 2 and it is running on Ubuntu Linux machine.
--------------------------------------------------------------------------------------------
Subdomain mapping to the folder will look as below:
http://sub1.example.com == http://example.com/sub1/
http://sub2.example.com == http://example.com/sub2/
---------------------------------------------------------------------------------------------
There is another solution which uses a .htaccess file. You need to put the file inside Apache 2 server web application directory: /var/www/html/.htaccess
RewriteEngine On
------ .htaccess file content as below ---
RewriteCond %{HTTP_HOST} ^sub1\.domain\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/sub1/
RewriteRule (.*) /sub1/$1
---------------------------------------------------------
But this way is inefficient, as mapped will contain subfolder name as well.
---------------------------------------------------------------------------------------------
So, we are providing this solution which will map

http://sub1.example.com == http://example.com/sub1/
http://sub2.example.com == http://example.com/sub2/

and will not show the folder name in the domain name. It will be internally handled by Apache 2 virtual host configuration.

---------------------------------------------------------------------------------------------
Many time website developers need to add the subdomain to their WordPress blog. This is how you can map the subdomain to subfolder WordPress blog.
--------------------------------------------------------------------------------------------
Links:
1. Image: https://drive.google.com/open?id=1Jz1...

2. Instructions file: https://drive.google.com/open?id=1ztg...

3. GoDaddy Configuration: https://drive.google.com/open?id=1jF-...