We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

URL redirection with wildcard DNS, Apache2

Shakthi777
Shakthi777 asked
on
Medium Priority
352 Views
Last Modified: 2012-05-11
Hi Experts,

I need to redirect 3 URLs via same Public IP. Currently the all the domain's DNS are hosted with Godaddy. (I'm pretty much sure about the Goddady configuration)

Below is the implementation requirement;

1. www.mydomain1.com to APP1 = works well
2. *.mydomain1.com to APP2 = works well (wild card DNS)
3. sub.mydomain2.com to APP3 = NOT WORKING

Below is the current configuration on Apache2 on CentOS 5.4

Please advise me on no 3 and thanks a lot for your time !


#### APP1 ####

<VirtualHost *:80>
 DocumentRoot /var/www/hosted/app1
 servername www.mydomain1.com
</VirtualHost>


#### APP2 ####

<VirtualHost *:80>
 DocumentRoot /var/www/hosted/app2
 servername mydomain1.com
 ServerAlias *.mydomain1.com
</VirtualHost>


#### APP3 ####

<VirtualHost *:80>
 DocumentRoot /var/www/hosted/app3
 servername sub.mydomain2.com
</VirtualHost>

##############

Open in new window

Comment
Watch Question

Dmitriy SkyIT Engeneer

Commented:
yes it' not working, try change 2 and 3 places..

2 app tells, that

ALL . mydomain1.com go to mydomain1.com

so get this in last place, or your apache server wont work with it, becouse second VirtualHost, accept rule:

sub.mydomain1.com also ;)

Author

Commented:
can you just advise me how to change it order to function as required ?

thanks a lot !
undersky,

I think this is not the case, because the third virtual host points to mydomain2.com and is not a subset of second vhost
What happens when you send a request for sum.mydomain2.com? You've got error messages on your browser? or some other application comes up instead of number 3?

Author

Commented:
aliganjei: when I access sub.mydomain2.com it just gave a blank page on Firefox and "Server Error" on Chrome
my you please check error_log of your server and tell us what happens?
maybe virtual host is working fine and something is wrong with your application?

Author

Commented:
on APP3 config I have changed mydomain2 to mydomain1 and now it's redirecting to the APP2 which is wild card DNS.

How do I fix this ???
#### APP1 ####

<VirtualHost *:80>
 DocumentRoot /var/www/hosted/app1
 servername www.mydomain1.com
</VirtualHost>


#### APP2 ####

<VirtualHost *:80>
 DocumentRoot /var/www/hosted/app2
 servername mydomain1.com
 ServerAlias *.mydomain1.com
</VirtualHost>


#### APP3 ####

<VirtualHost *:80>
 DocumentRoot /var/www/hosted/app3
 servername sub.mydomain1.com
</VirtualHost>

##############

Open in new window

here you should refer to Undersky's comment.
Just cut the lines for App3 and paste them befor App2

Author

Commented:
Dose it redirect the three URL respectively to the three applications ?
It should

Author

Commented:
aliganjei:  nope it's made non of them working...

try httpd -S
see if it reports any errors

Author

Commented:
aliganjei: "Syntax OK"
Well,
First look if this config works for you and all three applications are accessible:

 
#### APP1 ####

<VirtualHost *:80>
 DocumentRoot /var/www/hosted/app1
 servername www.mydomain1.com
</VirtualHost>


#### APP2 ####

<VirtualHost *:80>
 DocumentRoot /var/www/hosted/app2
 servername mydomain1.com
# ServerAlias *.mydomain1.com
</VirtualHost>


#### APP3 ####

<VirtualHost *:80>
 DocumentRoot /var/www/hosted/app3
 servername sub.mydomain1.com
</VirtualHost>

##############

Open in new window

In the event that you're still having issues, I would suggest troubleshooting it a bit more: remove everything but the third app ("/var/www/hosted/app3") and make sure it works.  The problem could be as simple as that application not working.
IT Engeneer
Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview
Dmitriy SkyIT Engeneer

Commented:
you can try change ports, and check, it works or not.. this one must work fine..

btw also check:


host mydomain1.com
host mydomain2.com
host sub.mydomain1.com


did DNS show it right?
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview

Author

Commented:
tnx !
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.