APACHE REDIRECT
- I have 2 VM of Centos also I used base machine:
1)
Centos – 192.168.0.102 (first.com)
192.168.0.103
(second.com)
2)
Centos – 192.168.0.104 (third.com)
3)
Base M/C (Windows) – 192.168.0.1 (Make entry of website and IP in hosts file).
- Client i.e. Base Machine send request for “first.com”, and the
request go to the VH and searches for “ServerName” and it gives priority to the
“Redirect” directive over “DocumentRoot”.
- “Redirect” tag told client that it has to redirected to
“third.com” and send the details of “third.com” and then client goes to the
client. (End user can see the details in Address Bar).
Practical
<SERVER>
1) Go to configuration file and in VH Section add “Redirect”
directive:
#
vim /etc/httpd/conf/httpd.conf
<VirtualHost
192.168.0.102:80>
ServerAdmin
webmaster@dummy-host.example.com
DocumentRoot
/opt/website_directory1
ServerName
first.com
Redirect
/ http://third.com (“/” is a “ServerName” of server i.e. first.com)
DirectoryIndex
index.php
ErrorLog
logs/dummy-host.example.com-error_log
CustomLog
logs/dummy-host.example.com-access_log common
</VirtualHost>
2) Reload the “httpd” service.
#
/etc/init.d/httpd reload
<CLIENT>
1) Go to client i.e. Base Machine and open browser, type there
http://first.com (In browser you can see
“third.com” and page of same)
Comments
Post a Comment