Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Apr 2011
    Posts
    48
    Thanks
    14
    Thanked 0 Times in 0 Posts

    Question htaccess users/username

    Hi all,

    Looking for a bit of help with my htaccess file.

    What i'm basicly trying to achieve is www.exampledomain.com/users/tim967 and then on that page it would show all of the information about the username tim967.

    I know a bit of php so ideally wanting to do it using that but the main problem is the htaccess file.

    Below is what i've got. Any ideas what it should be? (not really got the hang of this htaccess stuff just yet)

    Code:
    RewriteRule ^users/() index.php?p=users&username=$1 [L]
    Thanks

    Tim967

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Put any wildcard style in there. .+ would probably be the easiest. You can add whatever you like to make it more specific of course, but any wildcard between the () will be translated to the $1.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #3
    New to the CF scene
    Join Date
    Aug 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks! i have the same problem.

  • #4
    New Coder
    Join Date
    Apr 2014
    Location
    Daytona Beach, FL
    Posts
    45
    Thanks
    0
    Thanked 1 Time in 1 Post
    www.exampledomain.com/users/tim967

    RewriteRule ^users/() index.php?p=users&username=$1 [L]


    first off im going to tell you right off the back, the way you have your site set up is ignorant. Your index should be the front page of your website not a user based profiling index. So im not going to help you there. but i will give you an example.


    PHP file: ./profile.php
    Code:
    <?PHP
    echo $_GET["ID"] . "," . $_GET["USERNAME"];
    ?>
    HTACCESS:

    Code:
    RewriteRule ^profile/([0-9]+)/(^/)/?$ %{DOCUMET_ROOT}/profile.php?ID=$1&USERNAME=$2
    This will rewrite http://www.exampledomain.com/profile...ERNAME=Richard

    to

    www.exampledomain.com/profile/100/Richard

    or
    www.exampledomain.com/profile/100/Richard/


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •