rewrite folder -> ?user=$1, except if folder exists

Discuss practical ways rearrange URLs using mod_rewrite.

rewrite folder -> ?user=$1, except if folder exists

Postby psychodoggy » Mon Jan 24, 2005 1:04 pm

I've got the following .htaccess file...
------------------------------------------
RewriteEngine On
RewriteCond %{REQUEST_FILE} !/algemeen/
RewriteCond %{REQUEST_FILE} !/classes/
RewriteCond %{REQUEST_FILE} !/docs/
RewriteCond %{REQUEST_FILE} !/guestbook/
RewriteCond %{REQUEST_FILE} !/images/
RewriteCond %{REQUEST_FILE} !/kalender/
RewriteCond %{REQUEST_FILE} !/phpmyadmin/
RewriteCond %{REQUEST_FILE} !/popup/
RewriteCond %{REQUEST_FILE} !/save/
RewriteCond %{REQUEST_FILE} !/scripts/
RewriteCond %{REQUEST_FILE} !/test/
RewriteCond %{REQUEST_FILE} !/usage/
RewriteCond %{REQUEST_FILE} !/webalizer/
RewriteRule ^([^.]*)$ index.php?user=$1
------------------------------------------

the idea was to redirect www.domain.com/username to www.domain.com?index.php?user=username but exclude the existing dirs from being transformed.

Trouble is, it's not working...
when i go to /docs , it redirects to /docs/?user=docs
when i go to /docs/ , it shows the same result as /docs, but the address bar doesn't change.

Does anybody know how to make a rewrite rule to transform both /dir/ and /dir to ?user=dir , excluding the existing dirs from being transformed?
psychodoggy
 
Posts: 2
Joined: Mon Jan 24, 2005 12:55 pm

Postby Caterham » Tue Jan 25, 2005 2:30 am

Why don't you use
Code: Select all
RewriteRule ^([^./]+)$ /index.php?user=$1 [L]
(without the Conditions) where the RegEx should match only to domain.com/abc but not /ab.c /abc/

but the address bar doesn't change.
There is no forced external redirect specifyed, so there shouldn't be any redirect...
Caterham
 
Posts: 690
Joined: Fri Dec 10, 2004 1:30 pm


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 38 guests

cron