Reputation: 1864
Currently I have this code in .htaccess file to create a fake directory
e.g.
http://www.mysite.com/something.php
will then become
http://www.mysite.com/something
I am using the following code for that
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^(\w+)$ ./$1.php
but what I want to do now is allow users to have a url like
http://www.mysite.com/myusername
that url will then point to this page
http://www.mysite.com/profile.php?username=myusername
I just wanted to know if this was possible?
Upvotes: 1
Views: 1153
Reputation: 3028
use this,
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME}.php -f
RewriteRule ^(\w+)$ $1.php [L,NC]
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^([a-zA-Z0-9_.-]+)/?$ profile.php?username=$1 [L,NC,QSA]
Upvotes: 2