User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Linux Servers and Apache section within the Tech Talk category of DaniWeb, a massive community of 429,966 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,607 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Linux Servers and Apache advertiser: Programming Forums
Views: 2034 | Replies: 1
Reply
Join Date: Feb 2007
Posts: 1
Reputation: brian79 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
brian79 brian79 is offline Offline
Newbie Poster

Help mod_rewrite - RewriteRule help

  #1  
Feb 17th, 2007
I am fairly new to mod_rewrite, but what I'm trying to do is redirect HTTP requests from the format http://www.example.com/username to serve up content from a structured directory of users below my document root.

My document root is located at /var/www/html

To keep the usernames organized and secure, I have put them in /var/www/users/u/username where "/u" is the first alphanumeric character of "/username."

I cannot figure out the syntax of the rewrite rule. I think it should be something like this, but I know this isn't correct:

RewriteRule ^/(([a-z0-9])[a-z0-9]+)(.*) /var/www/users/$2/$1/$3

Can anybody help me figure out the correct syntax I'm looking for?
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Feb 2002
Location: Lawn Guylen, NY
Posts: 10,972
Reputation: cscgal is just really nice cscgal is just really nice cscgal is just really nice cscgal is just really nice cscgal is just really nice 
Rep Power: 32
Solved Threads: 116
Admin
Staff Writer
cscgal's Avatar
cscgal cscgal is online now Online
The Queen of DaniWeb

Re: mod_rewrite - RewriteRule help

  #2  
Feb 17th, 2007
I don't know regex well enough to pull out the first letter of a word but it would be something like ^([a-z])([a-z0-9]+)$ /users/$1/$1$2 where $1 represents 'u' and $2 represents 'sername'. I'm probably totally wrong so feel free to make fun of me.
Last edited by cscgal : Feb 17th, 2007 at 11:01 am.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Linux Servers and Apache Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Linux Servers and Apache Forum

All times are GMT -4. The time now is 11:43 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC