rewritemap?

Fix it!!

rewritemap?

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

Hi,

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

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 http://www.neverever.co.uk/design does not go to http://www.neverever.co.uk/journal/design. 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?

ucbones
ucbones
 

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

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

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 .co.uk/ 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...
seomike
 
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 15 guests

cron