Page 1 of 1

Use "subdirectory" in URL as variable...

Posted: Fri Feb 19, 2010 2:47 pm
by BlurryDude
I'm not sure how to word this, so I do apologize if the subject is inaccurate for this post, but I want to do the following:

Instead of this:
http://www.domain.com/?user=bob

I want to use this:
http://www.domain.com/bob

How do I do this?

Re: Use "subdirectory" in URL as variable...

Posted: Fri Feb 19, 2010 3:09 pm
by pickle
You'll have to use an .htaccess file and mod_rewrite. Something like this might work:

Code: Select all

RewriteEngine on
RewriteBase /
 
# don't rewrite if the requested file is an actual file or directory
RewriteCond %{REQUEST_FILENAME}  !-s
RewriteCond %{REQUEST_FILENAME}  !-d
 
RewriteRule ^(.*)$ http://www.domain.com/?user=$1

Re: Use "subdirectory" in URL as variable...

Posted: Fri Feb 19, 2010 3:25 pm
by BlurryDude
Thank you :) will this work on a Windows Server?

Re: Use "subdirectory" in URL as variable...

Posted: Fri Feb 19, 2010 3:59 pm
by pickle
Are you using Apache or IIS? mod_rewrite is only for Apache.