TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   General (http://www.talkphp.com/general/)
-   -   Threat subdomain as root (http://www.talkphp.com/general/4739-threat-subdomain-root.html)

maZtah 07-15-2009 09:50 AM

Threat subdomain as root
 
I have a domain where I want to use subdomains, but all via files in the root.

I've added a wildcard (*) A dns record on my domain so all subdomains link to the root per default.

Now I want, f.e., test.domain.com link to the root (domain.com/?id=5), but the subdomain has to remain the path. Still get me? (bla.domain.com has to link to domain.com/?id=6)

Like if i go to: http://another.domain.com/members/5/ it links to the members page in the root (members.php?id=5).

I think this is possible via htaccess, but not sure. Anyone?

Sam Granger 07-15-2009 02:55 PM

htaccess:
Code:

Options +FollowSymlinks
RewriteEngine On

Options -MultiViews

RewriteCond %{HTTP_HOST} !^www\.yourdomain\.com [NC]
RewriteCond %{HTTP_HOST} ^([a-z0-9]+)\.yourdomain\.com
RewriteRule (.*) _controller.php?username=%1&module=$1 [L,QSA]

Replace yourdomain with your domain name. The subdomain displays what ?username= returns so if you go to example.domain.com it displays _controller.php?username=example - however it doesnt show this, appears as the subdomain still. Going to example.domain.com/hi displays _controller.php?username=example&module=hi. If you bump into any problems, let me know :)

I'm not sure how you'd link it with the id but maybe that's because I've been staring at my screen too long. :-/

Sam Granger 07-16-2009 07:48 AM

Ah, silly me - make link from subdomain to id in the php file it calls :)


All times are GMT. The time now is 08:44 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0