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?
Use "subdirectory" in URL as variable...
Moderator: General Moderators
-
BlurryDude
- Forum Newbie
- Posts: 7
- Joined: Wed Feb 10, 2010 7:44 am
Re: Use "subdirectory" in URL as variable...
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=$1Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
-
BlurryDude
- Forum Newbie
- Posts: 7
- Joined: Wed Feb 10, 2010 7:44 am
Re: Use "subdirectory" in URL as variable...
Thank you
will this work on a Windows Server?
Re: Use "subdirectory" in URL as variable...
Are you using Apache or IIS? mod_rewrite is only for Apache.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.