Another very important option is the Redirect option, when we are going to use the Redirect option, it
is used to redirect some url/page to another one. To understand how this work.
we are going to create one additional page, new.html in our /var/www
/html/example1 directory and changed the VirtualHost setting for 172.24.0.1.
First, what we are going to do, we will go into /var/www/html/example1.
directory, we will list.
We will find that the index.html file is there. now, we will create one another, new.html
file.
We will name the file as new.html.
You can name, give any name here.
We are giving the name new.html and we will put some data here.
And in our case, we are putting the data "redirect to new page" then with a ls -l we are going
to list now we have got 2 files index.html.
and new.html
Now we want that when some person is going to access it by using 172.24.0.1, then what
should display, instead of this, it should redirect to new.html.
So what we have to do, we will go to our httpd.config file and on VirtualHost settings we are going
to make changes that mean for first section.
We are going to make the changes.
This parameter is same 172.24.0.1 ServerName is there DocumentRoot is there, this additional we have to
write.
We are saying that Redirect permanent that means permanent.
This resource has moved.
Which file, if somebody is going to access /index.html
where should it redirect
http://172.24.0.1/new.html
that mean because when we are going to test by using elinks
dump 172.24.0.1, the request will come to the Web server.
Web server will read this stanga and by default, it has to display the index.html.
But when it is going to read this directory, what will happen instead of displaying index.html
content it is going to display the contents of new.html.
We will test the syntax by using the service http configtest and then we will reload our httpd
server.