Solved

Page is not redirected using redirect in apache

Posted on 2013-12-11
5
286 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Learn by example how to specify CSS selectors for Selenium WebDriver test automation software.
Any business that wants to seriously grow needs to keep the needs and desires of an international audience of their websites in mind. Making a website friendly to international users isn’t prohibitively expensive and can provide an incredible return…
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

786 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