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.

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?

cheers

share|improve this question

migrated from stackoverflow.com 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. anotherdomain.com/foo/bar? 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 exampleDomain.com 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: serverfault.com/questions/37936/… –  Kevin Kuphal Aug 3 '09 at 20:05
add comment

3 Answers

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
1  
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
add comment

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> 

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

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
</VirtualHost>

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
add comment

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} !^exampledomain.com$
RewriteRule ^/(.*)$ http://exampledomain.com/exampledirectory/$1
share|improve this answer
add comment

Your Answer

 
discard

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