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 am setting up a couple micro sites that I would like to have their own url associated with. How can I redirect that url to a sub folder of an existing site?

for example, i might like to redirect http:/www.applesandstuff.com/ => http://www.cheeseandstuff.com/applesandstuff/

share|improve this question
    
Yes, sorry should have included the server; IIS 6.0 I think I may just use the host header redirection route suggested by mpbloch. –  user14323 Jul 24 '09 at 19:00
    
This how, for example, Office Live Small Business, and Google Apps for custom domains work. –  mpbloch Jul 24 '09 at 22:13

6 Answers 6

up vote 4 down vote accepted

You must have control of how the Web server handles requests at www.cheeseandstuff.com.

You then set up a conditional based on the HOST header, and set up a redirect to the path.

In your dns, you can use a CNAME to redirect "www" in applesandstuff.com to "www.cheeseandstuff.com". Or, to "applesandstuff.www.cheeseandstuff.com", for example, and set up your redirects on the web server to look for "(MATCH).www.cheeseandstuff.com" and redirect to the path "/(MATCH)".

share|improve this answer

You can do this in apache with mod_rewrite

RewriteRule   ^www\.applesandstuff\.org(.*)$      http://www.cheeseandstuff.org/applesandstuff$1 [NC,R,L]

About the flags:

  • NC: Not case sensitive
  • R: Redirect, change the url shown to the user. This is the opposite of proxy [P]
  • L: Final redirect, Don't apply any other rules if this matches.
share|improve this answer

You could use a basic 301 redirect in your .htaccess file that says something like the following:

redirect 301 / http://www.cheeseandstuff.com/applesandstuff

That will take anything going from the root of the site and redirect it to your other site

share|improve this answer

Request for more information: what web server are you using to serve the sites?

share|improve this answer

If you are using apache you want to use mod_rewrite

share|improve this answer

Agree with other posters, it really depends on what web server you are using. Even within IIS there are multiple ways to do it depending on which version of IIS you are running.

share|improve this answer

Your Answer

 
discard

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