using .htaccess

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
ganesh_dabhade
Forum Newbie
Posts: 19
Joined: Sun Feb 06, 2011 12:42 am
Contact:

using .htaccess

Post by ganesh_dabhade »

Hi friends, I m new to .htaccess and I need ur help in this problem

I want to access http://www.mysite.com/index.php?user=testuser as http://testuser.mysite.com/index.php
(these urls are for informative purpose only.)

I know this can be done using .htaccess readwrite rules.
Whenever a user registers, he should have its own subdomain.

please help me
thanks!
User avatar
tr0gd0rr
Forum Contributor
Posts: 305
Joined: Thu May 11, 2006 8:58 pm
Location: Utah, USA

Re: using .htaccess

Post by tr0gd0rr »

If all the subdomains point to the same web root, you may be able to put HTTP_HOST as a get param. Something like this?

Code: Select all

RewriteEngine On
RewriteBase /
RewriteRule ^(.*)$ $1?user=%{HTTP_HOST} [QSA,L]
That would set user = "testuser.mysite.com"

Not sure if that would work.
User avatar
ganesh_dabhade
Forum Newbie
Posts: 19
Joined: Sun Feb 06, 2011 12:42 am
Contact:

Re: using .htaccess

Post by ganesh_dabhade »

I have used
RewriteEngine On
RewriteRule ^([^/]+) /info.php?b=$1
It worked. But now I am not able to view my index.php file at the root. Instead It shows above page with b is equal to nothing.

Please help me solve this.
Post Reply