Forum Moderators: phranque

Message Too Old, No Replies

mysite.com/username

         

FiRe

9:42 am on Apr 22, 2009 (gmt 0)

10+ Year Member



I need some htaccess code to pick up if someone goes to www.mysite.com/username then run user.php?id=$1 or www.mysite.com/username?page=2 run user.php?id=$1&page=$2

Wordpress uses this:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

But I dont want to have to code index.php to check the REQUEST_URI etc.. is there another way as to my suggestion above?

g1smd

7:41 pm on Apr 22, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Grab the username and store it as a backreference, and then re-use it to append a parameter to the internal filepath.

Something like:

RewriteRule (.*) /index.php?user=$1 [QSA,L]