Solved

Apache virtual host redirection to URL

Posted on 2010-08-16
6
523 Views
Last Modified: 2013-11-30
Hi,

I need to redirect a domain to a specific file on my server and are not sure how.

I have 2 domains one had several files on that I like to have another domain link to.

e.g I have www.domain1.com/myfile.html

I like to configure domain to to link direct to this html page. I can not make it a directory which is the issue here it need to be the HTML page. Is there a way to configure the vhost of the second domain to link direct to this url of domain 1?


I did try the one below but it does not work

<VirtualHost xxx.xxx.xxx.xxx:80>
DocumentRoot /home/domain2/htdocs
ServerName domain2.com
ServerAdmin info@domain2.com
ServerAlias www.domain2.com
CustomLog /home/domain2/logs/access_log "special"
<Directory "/home/domain2/htdocs">
Options FollowSymLinks Includes IncludesNOEXEC
</Directory>
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_METHOD} !^(GET|POST|HEAD)$
RewriteRule $ http://www.domain1.my/myfilehtml [L]
</IfModule>
</VirtualHost>


Any help is appreciated.

Best wishes,
Thom
0
Comment
Question by:Thomanji
6 Comments
 
LVL 11

Expert Comment

by:Pieter Jordaan
ID: 33445730

Remove the domain2 vhost, and just add
ServerAlias www.domain2.com

to the vhost of domain1
0
 
LVL 6

Expert Comment

by:Joshua1909
ID: 33445740
Hi Thom,
Can you let me know a bit more about what you're trying to achieve? There a a few ways you can do this, but it would help to know more.
The first thing that comes to mind is that you can modify apache to look for your 'myfile.html' page in your web directory as the default page to load rather than index.html or whatever.


*Edit the files httpd.conf and srm.conf file and do the following:
Find this line.
DirectoryIndex index.html
and change it as follows:

DirectoryIndex index.shtml index.html

Of course, you can use any filename you wish.

*source: http://bignosebird.com/apache/a2.shtml

Cheers,
Josh
0
 
LVL 11

Expert Comment

by:Pieter Jordaan
ID: 33445761
Another way would be to just redirect domain2 to domain1 using an index.php file with the following contents:

<?php
header ('Location: http://www.domain1.com');
?>

I hope that helps.
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

Author Comment

by:Thomanji
ID: 33451112
Hi Guys,

I thank you for the feedback which is probably what i will do if I do not find anything else.

Let me explain a bit more what exactly i do.

I have a content management system that does not work with directory. So each page is something like domain1.com/some_page.html
The site in question is a home-improvement site.

lets say I have:
domain1.com/aircondition.html

and I have a second domain called
air-condition.com

now I want that when someone goes to air-condition.com he comes out on domain1.com/aircondition.html

of course I can do a php redirect like suggested by BitFreeze but I wondered if there is a way to do it from the httpd.conf file in apache.

I will try Joshua idea because I could just make aircondition.html the default page on the second domain.

Best wishes,
Thom
0
 
LVL 26

Accepted Solution

by:
arober11 earned 500 total points
ID: 33525819
If you want to keep your two separate virtual hosts, just remove the following line and re-start Apache:

RewriteCond %{REQUEST_METHOD} !^(GET|POST|HEAD)$
0
 

Author Closing Comment

by:Thomanji
ID: 33530180
Hi,

arober11 that did it, simple and works fine.

Thank you all for the help.

Best wishes,
Thom
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
FTP output from Wireshak 6 50
Cisco iWAN 8 46
Security Alert 2 43
cisco switch stacking 6 34
Short answer to this question: there is no effective WiFi manager in iOS devices as seen in Windows WiFi or Macbook OSx WiFi management, but this article will try and provide some amicable solutions to better suite your needs.
If your business is like most, chances are you still need to maintain a fax infrastructure for your staff. It’s hard to believe that a communication technology that was thriving in the mid-80s could still be an essential part of your team’s modern I…
After creating this article (http://www.experts-exchange.com/articles/23699/Setup-Mikrotik-routers-with-OSPF.html), I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

757 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

22 Experts available now in Live!

Get 1:1 Help Now