Need help with subdomain redirect please

Using a single web hosting account to host multiple sites

Need help with subdomain redirect please

Postby springdot » Fri Aug 11, 2006 1:17 am

Hi all

First post here, so hoping someone can help - I have searched the forum, but can't find anything that has really pointed me in the right direction.

Basically, I have a script with a database that is getting too large now, so I need new signups to be using a new version of my site/database with the old one still running for people currently using it. You can see from below it is a forum hosting site. I can't afford another server right now, so I need to use a subdomain on the same server for the new database until I can move it (the subdomain) onto a server of its own...

Now, I am using Plesk, and have configured a subdomain, s1.mydomain.com within which I have placed all the code for the "new" part of the site to run from.

The problem I am having is that I can't get the mod rewrite to work properly and show the new stuff when it is accessed, I keep getting redirected to the base domain. The setup of the domains/subdomains in Plesk is as follows :

The path to the main site is

/var/www/vhosts/mydomain.com/httpdocs/

and the path to the subdomain is :

/var/www/vhosts/mydomain.com/subdomains/s1/httpdocs/

My current .htaccess file (placed in the root of the main domain) is as follows :

Code: Select all
RewriteEngine On
RewriteBase /


RewriteCond %{HTTP_HOST} !^www
RewriteRule (.*) http://www.%{HTTP_HOST}/$1 [L,R]

RewriteCond %{REQUEST_URI} !^/forums/
RewriteCond %{REQUEST_URI} !^/images/
RewriteCond %{REQUEST_URI} !^/includes/
RewriteCond %{REQUEST_URI} !^/language/
RewriteCond %{REQUEST_URI} !^/cache/
RewriteCond %{REQUEST_URI} !^/db/
RewriteCond %{REQUEST_URI} !^/docs/
RewriteCond %{REQUEST_URI} !^/feedback/
RewriteCond %{REQUEST_URI} !^/templates/
RewriteCond %{REQUEST_URI} !^/admin/
RewriteCond %{REQUEST_URI} !^/banners/
RewriteCond %{REQUEST_URI} !^/config/
RewriteCond %{REQUEST_URI} !^/forums/admin/
RewriteCond %{REQUEST_URI} !^/forums/banners/
RewriteCond %{REQUEST_URI} !^/forums/cache/
RewriteCond %{REQUEST_URI} !^/forums/config/
RewriteCond %{REQUEST_URI} !^/forums/db/
RewriteCond %{REQUEST_URI} !^/forums/images/
RewriteCond %{REQUEST_URI} !^/forums/images/avatars/
RewriteCond %{REQUEST_URI} !^/forums/logos/
RewriteCond %{REQUEST_URI} !^/forums/images/smiles/
RewriteCond %{REQUEST_URI} !^/forums/includes/
RewriteCond %{REQUEST_URI} !^/forums/language/
RewriteCond %{REQUEST_URI} !^/forums/templates/
RewriteCond %{REQUEST_URI} !^/forums/xs_mod/
RewriteCond %{REQUEST_URI} !^/banners/
RewriteCond %{REQUEST_URI} !^/avatars/
RewriteCond %{REQUEST_URI} !^/logos/
RewriteCond %{REQUEST_URI} !^/smiles/
RewriteCond %{REQUEST_URI} !^/xs_mod/

RewriteRule ^([A-Za-z0-9_]*)/(.*) /forums/$2?%{QUERY_STRING}&mforum=$1&subfolder=1
RewriteRule ^([a-zA-Z0-9]+)$ http://www.mydomain.com/$1/ [R=301,L]


ErrorDocument 401 http://www.mydomain.com/401.htm
ErrorDocument 403 http://www.mydomain.com/403.htm
ErrorDocument 404 http://www.mydomain.com/404.htm


Now, I assumed if I just replicated that (and placed in the root of s1.mydomain.com) , but altered for s1.mydomain.com instead of www.mydomain.com, everything would work, but it isn't. I am getting redirected to www.mydomain.com still, and from what I can tell, the .htaccess is the root of the main domain is still dealing with the requests, even for s1.mydomain.com

I hope I've explained this OK, and that someone can help me out? What I basically need is for the site at www.mydomain.com and at s1.mydomain.com to operate completely independently of each other, but in the same way (eg - the .htaccess file rewrites requests for mydomain.com/forums?mforum=testforum to mydomain.com/testforum

I would like s1.mydomain.com/forums/?mforum=testforum to rewrite to s1.mydomain.com/testforum

Any help you could give would be very much appreciated.


Thanks
James
springdot
 
Posts: 2
Joined: Fri Aug 11, 2006 12:49 am

Postby richardk » Fri Aug 11, 2006 5:00 am

and from what I can tell, the .htaccess is the root of the main domain is still dealing with the requests, even for s1.mydomain.com

It can't be, they're in different paths (one isn't in a subdirectory of the other).

Clear your browser's cache, the 301 redirects are probably cached.

You should be able to condense it into this
Code: Select all
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

RewriteRule ^(forums|images|includes|language|cache|config|logos|smiles)(/.*)?$ - [L]
RewriteRule ^(docs|feedback|templates|admin|banners|avatars|xs_mod/db)(/.*)?$   - [L]

RewriteRule ^([A-Za-z0-9_]+)/(.*)$ /forums/$2?%{QUERY_STRING}&mforum=$1&subfolder=1 [L]
RewriteRule ^([a-zA-Z0-9]+)$ http://www.mydomain.com/$1/ [R=301,L]


ErrorDocument 401 http://www.mydomain.com/401.htm
ErrorDocument 403 http://www.mydomain.com/403.htm
ErrorDocument 404 http://www.mydomain.com/404.htm
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby springdot » Mon Aug 14, 2006 4:47 am

Thanks for the help - I'm not sure whether the requests were cached or not in the end, because I decided to do the second "site" differently in the end, and everything works nicely now :)

Thanks for the info on condensing the .htaccess, appreciate it - when I get a few minutes, I'll give this a go


Cheers
springdot
 
Posts: 2
Joined: Fri Aug 11, 2006 12:49 am


Return to Domain Handling

Who is online

Users browsing this forum: No registered users and 17 guests

cron