APACHE ALIAS-2

Alias Directive

 

Client send request as, http://first.com/folder1

 In this case, “ServerName” is matched but it will search for “/folder1” folder in “/opt/website_directory1”. In our case, make “folder1” directory in “/opt/website_directory1” and also create file in it.

 

REQUIREMENT

 

a) http://first.com

     DocumentRoot ----> /opt/website_directory1

 

b) http://first.com/folder1

     DocumentRoot ----> /mnt/website_directory2

 

c) http://first.com/folder2

     DocumentRoot ----> /usr/website_directory3

 

 

 

<SERVER>

1) Go to configuration file, and add below lines in VH (Virtual Host).

<VirtualHost 192.168.0.103:80>

                   ServerAdmin webmaster@dummy-host.example.com

                   DocumentRoot /opt/website_directory1

                   ServerName first.com

                   DirectoryIndex index.html

                   Alias /folder1 “/mnt/website_directory2”

                   Alias /folder2 “/usr/website_directory3”

                   ErrorLog logs/dummy-host.example.com-error_log

                   CustomLog logs/dummy-host.example.com-access_log common

</VirtualHost>

 

2) Make respective directory and file in it.

# mkdir /mnt/website_directory2 && cd /mnt/website_directory2

# vim index.html

# mkdir /usr/website_directory3 && cd /usr/website_directory3

# vim index.html

 

<CLIENT>

1) Open Browser and type:

http://first.com

http://first.com/folder1

http://first.com/folder2

 

(In “Alias”, it won’t work with port number. Also, if you have “.php” file in main section so you have to create .php file in other places also. In this case, it is “/mnt/website_directory2” & “/usr/website_directory3”)


Comments