Ni Le
Ni Le

Reputation: 199

How do I point to a specific directory using mod_rewrite?

Note: I cant use apache "virtualhosts" on my server, but I can use mod_rewrite.

I have two domains pointing to the same IP address.

They both go to the directory /public_html/www/.

What is the best way to make the "home" directory of one of the domains /public_html/www/somethingelse/?

Upvotes: 1

Views: 44

Answers (2)

Jon Lin
Jon Lin

Reputation: 143906

In the htaccess file in your document root add these:

RewriteEngine On
RewriteCond %{HTTP_HOST} www.domain2.com [NC]
RewriteCond %{DOCUMENT_ROOT}/somethingelse%{REQUEST_URI} -d [OR]
RewriteCond %{DOCUMENT_ROOT}/somethingelse%{REQUEST_URI} -f
RewriteRule ^(.*)$ /somethingelse/$1 [L]

Upvotes: 0

sfell77
sfell77

Reputation: 986

Sounds like a shared-hosting plan: there are generally domain redirect tools provided to you which will allow you to point additional domains to existing paths under your main account:

domain 1: /public_html/www

domain 2: /public_html/www/domain2

domain 3: /public_html/www/domain3

Upvotes: 1

Related Questions