Solved

Apache virtual host redirection to URL

Posted on 2010-08-16
6
525 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 

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

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
small, multi network, problem 3 84
Botnet detection help me please 21 86
DHCP for a guest wireless network 1 48
ssh setup on Cisco swith 11 46
Let’s list some of the technologies that enable smooth teleworking. 
I had an issue with InstallShield not being able to use Computer Browser service on Windows Server 2012. Here is the solution I found.
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…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

863 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

24 Experts available now in Live!

Get 1:1 Help Now