mod_rewrite - for usernames

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

  1. CANEHDN macrumors 6502a

    CANEHDN

    Joined:
    Dec 12, 2005
    Location:
    Eagle Mountain, UT
    #1
    I have a site that people will come to and have their usernames in the URL.
    www.mysite.com/someusername. If they visit the site with www.mysite.com/canehdn/products 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.

    --http://www.mysite.com/canehdn/test/ --> /replicated/test/index.php (Works correctly)

    --http://www.mysite.com/canehdn/test/index.php --> /replicated/index.php (Should go to /replicated/test/index.php)

    --http://www.mywakeupnow.com/canehdn/ --> doesn't work at all. should go to /replicated/index.php

    --http://www.mywakeupnow.com/canehdn/index.php --> /replicated/index.php (Works correctly)

    Any help on this would be super appreciated.

    Thanks everyone
     
  2. 960design macrumors 68000

    Joined:
    Apr 17, 2012
    Location:
    Destin, FL
    #2
    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

    PS
    --http://www.mywakeupnow.com/canehdn/ --> 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