Forum Moderators: phranque

Message Too Old, No Replies

Dynamic subdomain URL rewriting

         

praveenkumar

9:16 am on Mar 21, 2006 (gmt 0)

10+ Year Member



Hi,
I am a newbie in URL rewriting, I wanted show the user name as subdomain of the site.

Example:

[praveen.domain.com...] should be treated as [domain.com...] Where we will be having so many users.

Can you please help me in this regard.

Thanks in advance
Praveen
<snip>

[edited by: jdMorgan at 1:36 pm (utc) on Mar. 21, 2006]
[edit reason] No signatures, please. [/edit]

jdMorgan

8:39 pm on Mar 21, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This is a fairly simple problem. It might be helpful to review the many simliar threads already posted here (see the 'search' link on each page) and the documents cited in our forum charter [webmasterworld.com] and the tutorials in the Apache forum section of the WebmasterWorld library [webmasterworld.com].

Jim

praveenkumar

3:15 am on Mar 22, 2006 (gmt 0)

10+ Year Member



Sorry for not providing the code. I am using the following code in .htaccess file.

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?([^.]+)\.mydomain\.com
RewriteRule ^index\.php$ /index.php?user=%2 [L]

But it is not working. It is showing the Webhoting site default page where it usually shows if the domain is registered with them and no file is uploaded. So, I think it is treating this as a new domain when I access it as [praveen.mydomain.com....]

Please help me out, I have been trying this for the last 2days without any success.

jdMorgan

6:50 am on Mar 22, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In order to invoke your rewrite code (which looks OK), the request has to reach your server 'account' filespace.

In order to do that, you need two more things in addition to the rewrite code itself:

1) You must define an A record or a CNAME to support wild-card DNS in your domain's zone file.
2) Your host must allow wild-card subdomains, and pass requests for them to your server.

If either of these is missing, then your code won't even be executed.

Jim

praveenkumar

3:18 am on Mar 23, 2006 (gmt 0)

10+ Year Member



Thank you very much Jim,

I will pass your comments to my server administrator and let you know what they are saying. Basically I am a developer who have little knowledge about the server that is why I have wasted 2days on this:(

Thank you
Praveen

praveenkumar

2:57 pm on Mar 27, 2006 (gmt 0)

10+ Year Member



Hi Jim,

Now it is somewhat working but not completely. It is forwarding all teh members to the same URL.

[praveen.mydomain.com...] to [mydomain.com...]

It is not taking the Username from teh subdomain.

I am using:

RewriteCond %{REQUEST_URI}!^/index\.php
RewriteCond %{HTTP_HOST}!^www\.mydomain\.com
RewriteCond %{HTTP_HOST} ^([^.]+)\.mydomain\.com
RewriteRule ^$ /index.php?user=%1

Taken from one of your examples at [webmasterworld.com...]

Can you please suggest what might have gone wrong

Thanks
Praveen