How can I both redirect and rewrite a domain

Discussion in 'Apache' started by Darden12, Sep 2, 2008.

  1. #1
    I read the Apache FAQs that covered the redirection of a subdomain, but I have a slightly different problem.

    I am trying, if possible (without getting in trouble with Google or my provider) to host multiple domain names in the directories beneath my main domain. I so far have accomplished half of this plan by simply redirecting my newly created domain to a subdirectory under my main (original) domain that is hosted by my provider.

    In other words, my file structure looks something like this.

    /public_html
    --index.html (main page for MY_ORIGINAL_DOMAIN_NAME.COM)
    ----/SUBFOLDER_NAME
    -------index.html (main page for MY_NEW_DOMAIN_NAME.COM)

    My redirect makes MY_NEW_DOMAIN_NAME.COM load the index.html page in the SUBFOLDER listed above.

    So far, so good. My problem is with the URL that appears in the navigation bar after redirection is performed. The visible URL now starts with MY_ORIGINAL_DOMAIN_NAME.COM, which can be confusing for folks who accessed the page using MY_NEW_DOMAIN_NAME.COM

    I would like to rewrite this address to which I'm redirecting people, so that only the new domain name shows in the navigation bar. In other words, when they go to the address MY_NEW_DOMAIN_NAME.COM, I want them to see see something like this:

    NEW_DOMAIN.COM/index.html
    (or simply NEW_DOMAIN.COM)

    rather than something like this:

    MY_ORIGINAL_DOMAIN_NAME.COM/SUBFOLDER/Index.html

    I hope I've made my question clear. I basically want to know how to use an .htaccess file to rewrite a URL to which I'm already doing a redirect.

    Thanks,
    Brian
     
    Darden12, Sep 2, 2008 IP