Fix it!!


Postby ucbones » Thu Mar 11, 2004 3:23 am


I'm writing a simple journalling tool for a few friends, and want them to be able to use to access their journal, which is really stored (or rather, goes to the next bit of mod_rewrite) at

Clearly, mod_rewrite is the way to go, and I've made a start...

RewriteRule ^dom([/]?)(.*)$ journal/dom/$2

The next stage is to automate these rules, without knocking out my current folders, so that does not go to This will allow me to use automated sign-up (whilst checking that usernames chosen do not conflict with current folders), and so on!

I'm guessing the way to go about this is RewriteMap, but a quick google didn't yield any simple explanations. Any ideas?


Postby jshpro2 » Fri Nov 26, 2004 9:08 pm

I am a noob to rewrite but you could make a user go to /_username/ rather then /username/

then just not name any of your physical folders with a _ at the beging?

if it must be /username/ you could use a condition at signup

Code: Select all
if (isdir($newusername)) {
echo ("username not available");
} else {
echo ("youve been registerd $newusername");

Postby seomike » Mon Nov 29, 2004 5:49 pm

Code: Select all
# if it's not a real directory folder
RewriteCond %{REQUEST_URI} !-d [OR]
# if it's not a real file
RewriteCond %{REQUEST_URI} !-f
#rewrite anything from the till the first /
RewriteRule ^([^/]+)/?$ /journal/$1 [L]

Since the -d won't pick up a mod rewrite created folder as a directory on the server this will keep your script from processing directories that are tangable like /images/ etc...
Posts: 331
Joined: Thu May 06, 2004 7:36 pm
Location: Dallas

Return to Security with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 2 guests