subdomain handling in htaccess

New to mod_rewrite? This is a good place to start.

subdomain handling in htaccess

Postby w33 » Sun Dec 18, 2005 10:28 pm

I would like to use rewrite rule to handle a subdomain with htaccess (setting document root for a subdomain) but
http://test.mysite.com/aa
will cause to display
http://test.mysite.com/htmlroot/testdir/aa/

All other cases are working, except the one above.


I used this code:
Code: Select all
RewriteCond %{HTTP_HOST} ^test\.mysite\.com$  [NC]
RewriteCond %{REQUEST_URI} !^/htmlroot/testdir [NC]
RewriteRule ^(.*)  /htmlroot/testdir/$1  [L]


the rewrite rule log shows this:
(3) [per-dir C:/Work/mysite.com/] strip per-dir prefix: C:/Work/mysite.com/htmlroot/testdir/aa/ -> /htmlroot/testdir/aa/
(3) [per-dir C:/Work/mysite.com/] applying pattern '^(.*)' to uri '/htmlroot/testdir/aa/'
(4) RewriteCond: input='test.mysite.com' pattern='^test\.mysite\.com$' => matched
(4) RewriteCond: input='/htmlroot/testdir/aa/' pattern='!^/htmlroot/testdir' => not-matched
(1) [per-dir C:/Work/mysite.com/] pass through C:/Work/mysite.com/htmlroot/testdir/aa/


How to fix the rewrite rule so the
http://test.mysite.com/aa
should display
C:/Work/mysite.com/htmlroot/testdir/aa/



The following case also describes my goal:
My rules for that directory is as follows:
RewriteEngine on
Options +FollowSymlinks
RewriteCond %{HTTP_HOST} ^sub.domain.com$
RewriteRule ^sub.domain.com$ /public_html/directory2use/ [R,L]

I want it that when the sub.domain.com is accessed it's document root will be at /public_html/directory2use, but the uri will be still... sub.domain.com/

Can anyone help me with htaccess file rules, if its incorrect?


Any suggestion to fix the problem?
w33
 
Posts: 5
Joined: Sat Sep 27, 2003 4:44 pm

Postby seomike » Fri Dec 23, 2005 3:36 pm

Try using

/~htmlroot/testdir
seomike
 
Posts: 331
Joined: Thu May 06, 2004 7:36 pm
Location: Dallas


Return to Beginner's Corner

Who is online

Users browsing this forum: No registered users and 46 guests

cron