Mod Rewrite Help? .htaccess

Discussion in 'Programming' started by Josh-H, Jul 8, 2007.

  1. #1
    How do I get my site

    example.com

    so that when I go to example.com/Josh

    it shows

    example.com/profile.php?user=Josh

    Thanks.
     
    Josh-H, Jul 8, 2007 IP
  2. SeLfkiLL

    SeLfkiLL Active Member

    Messages:
    85
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    50
    #2
    Create a .htaccess file with this in it:

    
    RewriteEngine On
    RewriteRule ^(.*)$ profile.php?user=$1 [QSA,L]
    
    Code (markup):
     
    SeLfkiLL, Jul 8, 2007 IP
  3. Josh-H

    Josh-H Active Member

    Messages:
    406
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    55
    #3
    My bad but can I actually have it so its example.com/user/Josh instead of example.com/Josh as that messes up all of my files.

    Sorry.
     
    Josh-H, Jul 8, 2007 IP
  4. SeLfkiLL

    SeLfkiLL Active Member

    Messages:
    85
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    50
    #4
    If profile.php is in the root directory then it would be:

    
    RewriteEngine On
    RewriteRule ^user/(.*)$ profile.php?user=$1 [QSA,L]
    
    Code (markup):
    or if profile.php was in the directory "user" then it'd be

    
    RewriteEngine On
    RewriteRule ^user/(.*)$ user/profile.php?user=$1 [QSA,L]
    
    Code (markup):
     
    SeLfkiLL, Jul 8, 2007 IP