sending server values from htaccess to php

Discussion in 'PHP' started by rajeeilan, Sep 12, 2007.

  1. #1
    thanks for ur reply krt

    i want to send dynamic values from htaccess file to php


    for example any user my site should be redirected to his personal homepage. i want to fetch database from his username

    example.com/test user ...redirect to example.com/user.php?id='testuser'

    i'm eager to know this pls help me

    regards,
     
    rajeeilan, Sep 12, 2007 IP
  2. krt

    krt Well-Known Member

    Messages:
    829
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    120
    #2
    In your .htaccess file:

    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^([a-z0-9_-]+)$ user.php?id=$1 [NC, L]

    Note: this assumes usernames have only alphanumeric chars, hyphens or underscores

    Also, when you want to reply, use "Post Reply", do not start a new topic for each post as it gets confusing.
     
    krt, Sep 12, 2007 IP
  3. rajeeilan

    rajeeilan Peon

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    hi

    it shows an error like this

    The server encountered an internal error or misconfiguration and was unable to complete your request error code 500:
     
    rajeeilan, Sep 12, 2007 IP
  4. krt

    krt Well-Known Member

    Messages:
    829
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    120
    #4
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^([a-z0-9_-]+)$ user.php?id=$1 [NC,L]
     
    krt, Sep 14, 2007 IP