Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a server under one main domain, and I want to point another domain to /example/index.php to make another site.

Is there anyway i can do this with .htaccess?


share|improve this question

migrated from Aug 3 '09 at 20:00

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

It is possible (not with .htaccess files, but with the main server config file); but what should happen when you access e.g. Should it map to /example/index.php/foo/bar? The question needs to be more detailed to get a proper answer. – David Z Aug 3 '09 at 18:38
@David: When you go to I want the index.php file to be bought up from /exampleDirectory/index.php. 'exampleDirectory' is on a server in public_html. Does this help ? – Joe Aug 3 '09 at 18:52
Check out this answer to a nearly identical question:… – Kevin Kuphal Aug 3 '09 at 20:05

No, .htaccess is for other things.
What you need is:
1. Tell your domain registrar where are server located (IP address).
2. Modify web server configuration for particular domain name (google for virtual hosts in case of apache).
3. Wait until DNS's will update your domain name IP address all over the world.

share|improve this answer
Anyway, question is not clear. Please explain in detail, if my answer is not what you want to hear. – Andrejs Cainikovs Aug 3 '09 at 18:36

You can have two distinct sites by using the virtualhost facility, e.g. (just part of a much bigger configuration ...)

<VirtualHost *>
ServerName fct
DocumentRoot /home/mas/www/fct

<VirtualHost *>
ServerName frodch
DocumentRoot /home/mas/www/frodch

If you want to refer to part of the hierarchy of one site as another, this is possible in the same way, e.g. the second entry above could be

<VirtualHost *>
ServerName frodch
DocumentRoot /home/mas/www/fct/frodch

However, depending on the design of the site, this may work badly as pages in the 'frodch' heirarchy would probably still have links, defined as local, to resources that are not in the frodch heirarchy (perhaps to /img/... or /contacts.php and so on) and these would not be accessible.

A simpler approach can be to not define the new domain on the web host but to use the domain name host facility to, for example, do an HTTP redirect for the new domain name to the main domain's subdirectory. That way the user selecting the new domain arrives at the appropriate subdirectory page of the larger site but is still within the larger site so all the links and resources are available as usual.

share|improve this answer

It should be possible with .htaccess and mod_rewrite (apache webserver is required).

Put something like this in your .htaccess - file.

RewriteEngine On
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^/(.*)$$1
share|improve this answer

Your Answer


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