icon Get the most out of Surmunity, read our tips here! Need an interesting blog to read? You've got to read the Surpass Blog! | Welcome! Please register to access all of our features.
Old March 28th, 2006, 7:25 PM   #1 (permalink)
Registered User
Fresh Surpasser
 
Joined in Aug 2004
9 posts
Gave thanks: 0
Thanked 0 times
htaccess redirect

I'm not very good with rewrites or regex's. Can anyone please tell me how to setup a rewrite so that when someone on my site goes to

mysite.com/users/USERNAME

they are redirected to something like

mysite.com/users/setUser.php?user=USERNAME

thanks
brentayers is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old March 28th, 2006, 8:19 PM   #2 (permalink)
rocks your socks.
Resident.
 
David's Avatar
 
Joined in Mar 2004
Lives in fear of Obama.
Hosted on Pass 7
13,170 posts
Gave thanks: 8
Thanked 35 times
Quote:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteBase /


RewriteRule ^users/([A-Za-z0-9]+)$ /users/$1/ [R]
RewriteRule ^users/([A-Za-z0-9]+)/$ /users/setUser.php?user=$1 [L]

Try something like that. It should also make it redirect to user/username/ if they only put in user/username.
__________________
Quote:
Originally Posted by removed View Post
Internet Explorer rules.
David is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old March 28th, 2006, 8:27 PM   #3 (permalink)
All Ur Base R Belong 2 Us
Excelling Contributor
 
mr_fern's Avatar
 
Joined in Feb 2005
Lives in Vegas & New York
824 posts
Gave thanks: 2
Thanked 6 times
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} ^users/(.*)
RewriteRule (.*) /users/setUser.php?user=%1
__________________
Nobody doing nothing
mr_fern is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old March 28th, 2006, 8:28 PM   #4 (permalink)
All Ur Base R Belong 2 Us
Excelling Contributor
 
mr_fern's Avatar
 
Joined in Feb 2005
Lives in Vegas & New York
824 posts
Gave thanks: 2
Thanked 6 times
oh.. d already posted... shucks, this is what i get for idling away from the computer before replying
__________________
Nobody doing nothing
mr_fern is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old March 28th, 2006, 8:28 PM   #5 (permalink)
rocks your socks.
Resident.
 
David's Avatar
 
Joined in Mar 2004
Lives in fear of Obama.
Hosted on Pass 7
13,170 posts
Gave thanks: 8
Thanked 35 times
Yeah, but yours looks more simpler lol
__________________
Quote:
Originally Posted by removed View Post
Internet Explorer rules.
David is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old March 28th, 2006, 9:35 PM   #6 (permalink)
Registered User
Fresh Surpasser
 
Joined in Aug 2004
9 posts
Gave thanks: 0
Thanked 0 times
Yeah, mr_fearn's didn't intimidate me as bad as David's. I'll try them both though. Thanks for the help guys

Brent
brentayers is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old April 21st, 2006, 8:23 PM   #7 (permalink)
Registered User
Fresh Surpasser
 
Joined in Aug 2004
9 posts
Gave thanks: 0
Thanked 0 times
Ok, so I have one more for you. I'm trying to set so that when someone goes to *virtualhost*.mysite.com, it redirects them to mysite.com/browse/*virtualhost*

this is what I've got so far, but it's not working:

RewriteCond %{HTTP_HOST} (.*).mysite.com [nc]
RewriteRule ^/(.*) http://mysite.com/browse/$1


Thanks again for helping me with the last one, it worked great.
brentayers is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old April 22nd, 2006, 12:31 AM   #8 (permalink)
rocks your socks.
Resident.
 
David's Avatar
 
Joined in Mar 2004
Lives in fear of Obama.
Hosted on Pass 7
13,170 posts
Gave thanks: 8
Thanked 35 times
your use of * is confusing me as to what you're actually trying to do

This may help: http://www.yourhtmlsource.com/sitema...rewriting.html
__________________
Quote:
Originally Posted by removed View Post
Internet Explorer rules.
David is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old April 22nd, 2006, 4:15 AM   #9 (permalink)
Registered User
Fresh Surpasser
 
Joined in Aug 2004
9 posts
Gave thanks: 0
Thanked 0 times
Thanks David. I checked that site out but it's still really confusing to me. I would like to make it so that when somebody goes to virtualhost.mysite.com they are redirected to mysite.com/browse?dir=virtualhost.

I hope that's a little clearer, it's 3:13 a.m. where I'm at and my brain is a little bit fried right now trying to work on this thing.

Thanks again for all your help
brentayers is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On