PDA

View Full Version : [TechQ] Subdomain as URL mask (but not defaulting to home page)


ajsuk
10-10-2006, 05:44 AM
Hey there!

I'm looking in to using a subdomain to mask my main domain URL but not default to home page (which is the point in the subdomain ;) )

Anyway, what I'd effectivly like to do is make:

subdomain.mydomain.com act as mydomain.com?page=page2 but mask, not forward and still be able to navigate.

I've trawled the net looking for a solution and have found a couple of PHP(which is what I'm using) and .htaccess things but I can't find anything like what I want to do or adapt anything similar to do what I want.

Any and all help would be greatly appreciated,

Thanks in advance!

Andy.

ajsuk
10-15-2006, 09:40 AM
*bump*

Anyone? :)

areidmtm
10-15-2006, 12:20 PM
Try something like this

Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} ^([^\.]+)\.domain\.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/?page=$1 [QSA,L]

ajsuk
10-15-2006, 12:34 PM
Try something like this

Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} ^([^\.]+)\.domain\.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/?page=$1 [QSA,L]


Hey, thanks for the reply.

That does indeed work to some extent if I change the http://www.domain.com/?page=$1 to
http://www.domain.com/?page=1 to make the address right.

It doesn't seem to mask the URL though, more of a redirect action.

Is there anyway to keep the subdomain address in there? If not then I can live with it, but just thought I'd ask.

Thanks again!

areidmtm
10-15-2006, 01:10 PM
How about this then..this seamed to work in my test

Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www.)?([^\.]+)\.domain\.com$
RewriteRule ^(.*)$ http://www.domain.com/?member=$1 [nc]


Also a good place to check it out would be http://forum.modrewrite.com/

ajsuk
10-15-2006, 01:26 PM
That one seems to just redirect to the main domain.

Will check out that link, thanks.