Forum Moderators: phranque

Message Too Old, No Replies

mod_rewrite Subdomain folders

         

kambodianboi

12:04 am on Feb 15, 2006 (gmt 0)

10+ Year Member



Hi there,

I need help with the mod_rewrite, I have scripted my site, but just need the mod_rewrite to workout. Im trying to do this.

[(username).domain.com...] -> [domain.com...]

and

[(username).domain.com...] -> [domain.com...]

I dont know if thats possible, but any help is great!

This is what I have so far on my .htaccess.


RewriteRule ^\.htaccess$ - [F]
RewriteCond %{HTTP_HOST}!^www\.domain\.com?$
RewriteCond %{HTTP_HOST} ^([^.]+)\.domain\.com?$
RewriteRule ^(.*)$ user.php&u=%1 [L]

Thanks

jdMorgan

12:46 am on Feb 15, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



kambodianboi,

Welcome to WebmasterWorld!

I think this would be closer:


RewriteRule ^\.htaccess$ - [F]
#
RewriteCond %{HTTP_HOST} !^www\.domain\.co
RewriteCond %{HTTP_HOST} ^([^.]+)\.domain\.co
RewriteRule ^editprofile/?$ /user.php?uid=%1&mode=editprofile [L]
#
RewriteCond %{HTTP_HOST} !^www\.domain\.co
RewriteCond %{HTTP_HOST} ^([^.]+)\.domain\.co
RewriteRule ^/?$ /user.php?uid=%1 [L]

Jim

kambodianboi

1:41 am on Feb 15, 2006 (gmt 0)

10+ Year Member



Thanks jdMorgan,

It works, but by any chance can it be a changable mode?

For Example.
[(username).domain.com...] -> [domain.com...]

But instead of adding this code for every mode.


RewriteCond %{HTTP_HOST}!^www\.domain\.com
RewriteCond %{HTTP_HOST} ^([^.]+)\.domain\.com
RewriteRule ^editprofile/?$ /user.php?uid=%1&mode=editprofile [L]

If there isn't a way, it shouldn't be a problem.

Thanks agian.

kambodianboi

6:54 am on Feb 15, 2006 (gmt 0)

10+ Year Member



Never mind, I got it figured out. This is what I have now, so people can use it :D .


RewriteRule ^\.htaccess$ - [F]
RewriteCond %{HTTP_HOST}!^www\.domain\.com
RewriteCond %{HTTP_HOST} ^([^.]+)\.domain\.com
RewriteRule ^([^/\.]+)/?$ /user.php?uid=%1&mode=$1 [L]
#
RewriteCond %{HTTP_HOST}!^www\.domain\.com
RewriteCond %{HTTP_HOST} ^([^.]+)\.domain\.com
RewriteRule ^/?$ /user.php&uid=%1 [L]

Thanks agian :D