Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: .htaccess RewriteRule map URL to another  (Read 7700 times)

0 Members and 1 Guest are viewing this topic.

nuttynibbles

    Topic Starter


    Rookie

    .htaccess RewriteRule map URL to another
    « on: April 18, 2010, 08:21:32 AM »
    hi,

    I've developed a web program and let say the main url is http://domain.com

    I will be distributing different URLs for different users, say http://domain.com/user1
    and http://domain.com/user2

    however, both this URLs will be pointing to the base code at http://domain.com
    depending on whether is user1 or user2, the system configuration will extract from the respective database.

    my question is, how do i use mod_rewrite to map the different urls to the main url with transparency.

    I've managed to do it with alias in httpd.conf. e.g:
    alias /user1 /var/www/html/myproject
    alias /user2 /var/www/html/myproject

    however, if i were to do this, i would have to restart apache every time i've got a new user. so i've decided to use .htaccess instead but realised that alias is not availble for it.

    I've tried with rewriterule but with no success.

    Please advise. thank you
    « Last Edit: April 18, 2010, 08:42:47 AM by nuttynibbles »

    mr-bisquit

    • Guest
    Re: .htaccess RewriteRule map URL to another
    « Reply #1 on: April 18, 2010, 01:08:09 PM »

    Cityscape



      Adviser

    • Running Debian 8, Linux Mint and Windows 10.
    • Thanked: 15
      • Yes
    • Certifications: List
    • Computer: Specs
    • Experience: Experienced
    • OS: Linux variant
    Re: .htaccess RewriteRule map URL to another
    « Reply #2 on: April 18, 2010, 01:48:56 PM »
    http://www.linuxquestions.org

    Go there and ask.
    Yes, there are many helpful people at Linux Questions who could help you with this.

    nuttynibbles

      Topic Starter


      Rookie

      Re: .htaccess RewriteRule map URL to another
      « Reply #3 on: April 18, 2010, 07:30:26 PM »
      thanks guys. that nv cross my mind

      kpac

      • Web moderator


      • Hacker

      • kpac®
      • Thanked: 184
        • Yes
        • Yes
        • Yes
      • Certifications: List
      • Computer: Specs
      • Experience: Expert
      • OS: Windows 7
      Re: .htaccess RewriteRule map URL to another
      « Reply #4 on: April 20, 2010, 10:15:03 AM »
      There are also plenty of people here who could help.

      Code: [Select]
      Options +FollowSymLinks
      RewriteEngine on

      RewriteCond %{REQUEST_FILENAME} -f
      RewriteCond %{REQUEST_FILENAME} -d
      RewriteRule . - [L]

      RewriteRule ^/user([0-9]+)$ user\.php?id=$1 [QSA,L,NC]