Solved

Page is not redirected using redirect in apache

Posted on 2013-12-11
5
280 Views
Last Modified: 2013-12-19
hi,

I have implemented the mod_redirect in the httpd conf file.

Below is the source code.

<VirtualHost *:80>
    DocumentRoot /htdocs
      RewriteEngine On
      RewriteCond %{SERVER_PORT} 80
      RewriteRule (.*)/hello\.html$ http:localhost/contact_us.html [R=301,L]
</VirtualHost>

Now i run the code on browser
http://localhost/hello.html

The url is redirected but the page contact_us is not opened.The reason behind is
The url "http://localhost/" is appended to the "http:localhost/contact_us.html"
Below is displayed in the address bar.

http://localhost/http:localhost/contact_us.html

Please suggest how to solve the problem so that the url is redirected to

http:localhost/contact_us.html.
0
Comment
Question by:Rocking
5 Comments
 
LVL 1

Expert Comment

by:sulistyanto
ID: 39711742
try to set AllowOverride all

example :
   
 DocumentRoot /var/www
        <Directory />
                Options FollowSymLinks
                AllowOverride all
        </Directory>

Open in new window

0
 

Author Comment

by:Rocking
ID: 39711761
tried as per suggestion but not working.
0
 
LVL 26

Assisted Solution

by:skullnobrains
skullnobrains earned 334 total points
ID: 39715441
use either

RewriteRule (.*)/hello\.html$ http://localhost/contact_us.html [R=301,L]
(notice the missing // after http: )

or

RewriteRule (.*)/hello\.html$ /contact_us.html [R=301,L]
0
 
LVL 4

Assisted Solution

by:Ramakanta Sahoo
Ramakanta Sahoo earned 166 total points
ID: 39728834
try below:

RewriteRule ^hello\.html$  contact_us.html [R=301,L]
0
 
LVL 26

Accepted Solution

by:
skullnobrains earned 334 total points
ID: 39728975
or rather
RewriteRule /hello\.html$ /contact_us.html [R=301,L]
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
This video teaches users how to migrate an existing Wordpress website to a new domain.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now