SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Thread: mod_rewrite

  1. #1
    SitePoint Member
    Join Date
    Nov 2009
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    mod_rewrite

    Hello does anyone know how to do this using mod_rewrite

    www.domain.com/1234 (the 1234 is a random number)

    into

    www.domain.com?u=1234 which is accessed as normal.

    Is there an easier way?

    Lewis

  2. #2
    SitePoint Wizard PHPycho's Avatar
    Join Date
    Dec 2005
    Posts
    1,201
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    using following code in .htaccess:

    Code:
    Options -Indexes
    Options +FollowSymlinks
    
    RewriteEngine on
    #RewriteBase /
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-l
    
    RewriteRule ^([0-9]+)$ index.php?u=$1 [QSA,L]

  3. #3
    SitePoint Member
    Join Date
    Nov 2009
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've tried that but it ain't working

    What I want is

    if a user types in www.domain.com/1234

    i want PHP to read it as domain.com?u=1234.

    What am I doing wrong.

    Thanks for the help.

    Lewis

  4. #4
    SitePoint Guru deepM's Avatar
    Join Date
    Dec 2007
    Location
    India
    Posts
    705
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    lewisb87,

    You will get more help here

    http://www.sitepoint.com/forums/forumdisplay.php?f=199

  5. #5
    SitePoint Wizard PHPycho's Avatar
    Join Date
    Dec 2005
    Posts
    1,201
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by lewisb87 View Post
    I've tried that but it ain't working

    What I want is

    if a user types in www.domain.com/1234

    i want PHP to read it as domain.com?u=1234.

    What am I doing wrong.

    Thanks for the help.

    Lewis
    What's the error BTW.
    Post the error log file if available.
    Thanks

  6. #6
    SitePoint Member
    Join Date
    Nov 2009
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi

    How would I test this out to see if it's working?

    Thanks

    Lewis


Bookmarks

Posting Permissions

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