[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Page is not redirected using redirect in apache

Posted on 2013-12-11
5
Medium Priority
?
296 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 27

Assisted Solution

by:skullnobrains
skullnobrains earned 1336 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 664 total points
ID: 39728834
try below:

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

Accepted Solution

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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
The first step to building an amazing About page is to figure out what you want the page to say about your company. You then must grab the attention of the reader, boast a bit, tell a story and let others brag about you. With a little bit of thought…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses
Course of the Month18 days, 18 hours left to enroll

834 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