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

I have a subdomain named http://arun.rocks.com and another domain named www.rocks.com/projects/main.php/. I want my subdomain to always redirect to www.rocks.com/projects/main.php/. How to do this? Kindly help

share|improve this question

migrated from stackoverflow.com Apr 15 '10 at 3:56

This question came from our site for professional and enthusiast programmers.

    
Are you using IIS or Apache? –  Stefan Kendall Apr 13 '10 at 17:13
1  
http://arun.rocks.com is not a domain name... Neither is www.rocks.com/projects/main.php/ –  bortzmeyer Apr 14 '10 at 7:00
2  
@bortz - how is that relevant? The answer will still be the same... –  Mark Henderson Apr 15 '10 at 4:03
    
Given that this question didn't originate on SF we need to be a little more forgiving of incorrect and/or misunderstood terminology. –  John Gardeniers Apr 15 '10 at 4:13
    
@Farseeker: because if the question is unclear, the answers will be more difficult to write and less likely to be correct. –  bortzmeyer Apr 15 '10 at 6:43

3 Answers 3

To do all of this, I assume that you have access to the DNS for the domain, OR that the DNS has already been configured.

If the DNS is not configured, you will need to create a record for arun.rocks.com in your DNS so that it resolves to an IP address (you can do this with either an A or a CNAME record, depending on your purpose).

Then, you will need to set up a website to listen on the IP address you assigned in the DNS, with the hostname arun.rocks.com. You don't state if this is Apache or IIS, so you will need to look up the instructions on how to do that.

After you have a website running on arun.rocks.com (even if there's nothing in it), then you can tell the browser to redirect when you hit that page. You can do this dozens of ways. You could write a PHP or ASP page that does the redirection (outputting a 302-redirect), or you could do it with Javascript and plain HTML. Hell, you can even do it with a META tag on your HTML page.

Some DNS providers (such as www.dnsmadeeasy.com) will do this service for you so you don't need to do anything except register the DNS and set up the redirect there, but note that it is NOT the DNS doing the redirect, it's just a value-add service that the DNS provider gives.

share|improve this answer

If you're running Apache, adding lines similar to this to httpd.conf will do the trick:

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
RewriteRule ^(.*) $ http://www.example.com$1 [R=301]

Also make sure this one is present in the file somewhere. It's usually there by default though.

LoadModule rewrite_module libexec/apache22/mod_rewrite.so

Note: Your paths, version number, and domain may be different. With more detail, we can refine this answer to be exactly what you need.

share|improve this answer

Sounds like you need a domain name redirect in your DNS record. More info in this discussion thread: http://www.webmasterworld.com/forum23/1025.htm

share|improve this answer
1  
There's no such thing as a "domain name redirect" at the DNS level, there's CNAMEs but they're quite different. –  Mark Henderson Apr 15 '10 at 3:58

Your Answer

 
discard

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