Solved

Apache virtual host redirection to URL

Posted on 2010-08-16
6
532 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Schedule a Tour of the ATEN booth at InfoComm 2017

Tour the ATEN booth to see the the Latest Addition to the Modular Matrix Switch Series, New 4K HDMI Over IP Extender and more! Enter ATEN's Ultimate Giveaway Sweepstakes for a chance to win one of several great prizes, including an ATEN US7220 2-Port Thunderbolt 2 Sharing Switch!

 

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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

This article is a collection of issues that people face from time to time and possible solutions to those issues. I hope you enjoy reading it.
WARNING:   If you follow the instructions here, you will wipe out your VTP and VLAN configurations.  Make sure you have backed up your switch!!! I recently had some issues with a few low-end Cisco routers (RV325) and I opened a case with Cisco TA…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Suggested Courses

688 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