FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

Mod rewrite subdomain

 


DanielXP
Hi.

I want to use a sorta mod rewrite so i can let people have there own url for the profile.

i want it to be

theirname.mysite.com

But at the moment i am using this domain with a directory "http://rmb-scripting.com/rmb-space/" already on my site (until the site is fully made i wont buy the domain)

I was wondering how can i do this modrewrite?

Thanks.
Daniel
alalex
I'm not an expert on mod rewrite but I think it would go something like this:

Code:
# this is the initialization
Options         +FollowSymLinks
RewriteEngine   On

# these are the rewrite conditions
RewriteCond     %{REQUEST_FILENAME}     !-f
RewriteCond     %{REQUEST_FILENAME}     !-d

# and finally, the rewrite rules
RewriteRule     $^.(+[a-zA-Z0-9\-])?    /real_profile.php?user=$1 [L,QSA]


Ok, so I'll explain what this is supposed to do:
It will take all urls like: http://username.yourdomain.com and it will secretly redirect them to http://yourdomain.com/real_profile.php?user=username keeping the username.

Now you should change the "real_profile.php?user=username" with the page that contains the profile. Also, to let the page know which username you are asking for you should keep the GET variable. Its the only way that the mod rewrite can send the username...
The first line "+FollowSymLinks" makes sure that any sort of GET variable you send to the profile like: http://username.yourdomain.com/?whatever=whatever gets also redirected, so it would end up being: http://username.yourdomain.com/real_profile.php?user=username&whatever=whatever

I'm not sure if it will work, test it and if it doesn't post here the url where you are testing and I'll try to see why it doesn't


PS: A moderator should change this topic to PHP, cause that way you would reach more people that know about this Wink
DanielXP
Thanks for your reply.

I seem to be getting a server not found error when i go to like.

blah.rmb-scripting.com/rmb-space/

It don't seem to work.
alalex
Oops
Yes.. It seems to not be redirecting the users to the appropriate page

I'm not sure of what the problem is, but try with different combinations, here is one that might help...
Code:
$^.(+[-a-zA-Z0-9\-])?


I know that this script works because I have a very similar one where the users custom page is:
http://yourdomain.com/username
And it gets redirected to
http://yourdomain.com/userinfo.php?user=username

And the code I used is the same as the first one I posted but with:
Code:
RewriteRule     ^([a-zA-Z0-9\-]+)/?$    /userinfo.php?user=$1 [L,QSA]

This final line... Sad

So I'm guessing that there must be a combination that works for your problem, it is either that or that you can't rewrite subdomains... Sad
alalex
I've just found a blog entry that talks about all this, check it out, it may say what you need:

http://www.crucialwebhost.com/blog/htaccess-apache-rewrites-oh-my/
Reply to topic    Frihost Forum Index -> Scripting -> Html, CSS and Javascript

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.