mod_rewrite - for usernames

Discussion in 'Web Design and Development' started by CANEHDN, Aug 30, 2012.

  1. CANEHDN macrumors 6502a


    Dec 12, 2005
    Eagle Mountain, UT
    I have a site that people will come to and have their usernames in the URL. If they visit the site with it should internally redirect to /replicated/products/.

    I'm trying to get it so when people do this apache internally redirects to:
    /replicated/ --> dir & files in here. This is what I currently have.

    RewriteEngine On

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)\/(.+)$ /replicated/$2 [QSA,L]

    This is kind of working.

    -- --> /replicated/test/index.php (Works correctly)

    -- --> /replicated/index.php (Should go to /replicated/test/index.php)

    -- --> doesn't work at all. should go to /replicated/index.php

    -- --> /replicated/index.php (Works correctly)

    Any help on this would be super appreciated.

    Thanks everyone
  2. 960design macrumors 68030

    Apr 17, 2012
    Destin, FL
    Remove the username from the url all together, store it as a session (salted if you are worried ).

    Otherwise you could use a lead string to identify the username as such, something like user_bobd, then use the user_ as the strip point.

    just trying to imagine this

    -- --> doesn't work at all. should go to /replicated/index.php
    Try commenting out the !-d rewrite, that should get this to work

Share This Page