1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

mod_rewrite question

Discussion in 'General Scripting Chat' started by Porthos, Jun 25, 2012.

  1. Porthos

    Porthos Newbie

    Joined:
    Jun 23, 2012
    Messages:
    38
    Likes Received:
    2
    Lets say I have a membership site that I want to let users have clean URLS to their profiles.

    I would have a script, like `userprofile.php`, which I want the mod rewrite to call to when a visitor accesses mysitedotcom/aUserName, passing through the username as a GET variable for the script like so `userprofile.php?username=aUserName`.

    How would I go about making the rewrite for this?
     
  2. Porthos

    Porthos Newbie

    Joined:
    Jun 23, 2012
    Messages:
    38
    Likes Received:
    2
    I did some reading in other posts and the only thing I came up with was:
    Code:
    RewriteRule ^(.*)$ ?username=$1
    
    However would this interfere with other pages say I were to make mysitedotcom/forums I wouldnt want it redirecting to userprofiles.php?username=forums