•
•
•
•
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
![]() |
•
•
Join Date: Feb 2007
Posts: 1
Reputation:
Rep Power: 0
Solved Threads: 0
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?
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?
•
•
Join Date: Feb 2002
Location: Lawn Guylen, NY
Posts: 10,972
Reputation:
Rep Power: 32
Solved Threads: 116
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.
Dani the Computer Science Gal
Do you run a computer-related website? Feature it in our niche link directory!
Do you run a computer-related website? Feature it in our niche link directory!
![]() |
•
•
•
•
•
•
•
•
DaniWeb Linux Servers and Apache Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
apple bbc cd cellphone choose code computer core debian dell desktop development drivers enterprise fedora fiji games gentoo gpl hardware ibm infrastructure install kernel laptop linux marketing microsoft mobile news novell open open source openoffice operating os palm preinstall red hat rhel security server source sun system ubuntu unix vista web windows
- vBulletin mod_rewrite (PHP)
- [Revised] vBulletin Mod_rewrite Tutorial (PHP)
- vBulletin mod_rewrite in phpBB mod format (Existing Scripts)
- php rewrite question (PHP)
- Apache mod_rewrite with Google Ads (Linux Servers and Apache)
Other Threads in the Linux Servers and Apache Forum
- Previous Thread: Using Apache for local testing on Windows
- Next Thread: Domino Server Problem



Linear Mode