Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Helo,

I want to redirect my subdomain to an internal URL.

For example when user types in someaddress.com he should see a homepage

but when xxx.someaddress.com is typed in I'd like to open http://someaddress.com/testpage

How to achieve this?

I already tried with:

<VirtualHost *:8089>
    DocumentRoot "c:\app"
</VirtualHost>

<VirtualHost sms.localhost:8089>
    ServerName smslocalhost
    Redirect permanent / http://localhost:8089/testpage
</VirtualHost>

Problem is that whatever I type in now, I get redirected to http://localhost:8089/testpage

share|improve this question
add comment

1 Answer

I'm not sure your first vhost definition is doing anything so everything is being processed by the second definition. Try

<VirtualHost *:8089>
    ServerName localhost
    DocumentRoot "c:\app"
</VirtualHost>

<VirtualHost sms.localhost:8089>
    ServerName sms.localhost
    Redirect permanent / http://localhost:8089/testpage
</VirtualHost>

EDIT: From the comments.

NameVirtualHost *:8089

fixed the problem.

share|improve this answer
    
Thanks for your reply. I tried this already. First definition had "ServerName localhost" and the second one had "ServerName sms.localhost". It didn't work. –  Goran Jul 21 '11 at 9:36
    
You did remember to put an entry for sms.localhost in your %WINDIR%\System32\drivers\etc\hosts file didn't you? –  Iain Jul 21 '11 at 9:47
    
Yes. "127.0.0.1 sms.localhost" –  Goran Jul 21 '11 at 9:50
1  
@Goran: I just tested the exact configuration above on a wamp server and it works exactly as you want. –  Iain Jul 21 '11 at 10:26
    
When I added NameVirtualHost *:8089 everything started working. –  Goran Jul 21 '11 at 11:06
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.