Apache mod rewrite help

Discussion in 'Apache' started by cedricd, Nov 5, 2008.

  1. #1
    Hey all,

    My website has links like this:

    index.php?id=x
    index.php?id=x&gal=x

    How can I make it so I can use http://www.example.com/index.php/id/x andhttp://www.example.com/index.php/id/x/gal/x

    Thanks
     
    cedricd, Nov 5, 2008 IP
  2. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #2
    Options +FollowSymLinks +Indexes
    RewriteEngine on
    RewriteBase /
    RewriteRule ^id/([^.]+)/gal/([^.]+)$ index.php?id=$1&gal=$2 [L]
    RewriteRule ^id/([^.]+)$ index.php?id=$1 [L]

    example.com/id/x
    example.com/id/x/gal/x
     
    Nintendo, Nov 6, 2008 IP
  3. varunkrish

    varunkrish Peon

    Messages:
    107
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    varunkrish, Nov 6, 2008 IP
  4. cedricd

    cedricd Active Member

    Messages:
    10
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    88
    #4


    Thanks so much! :D

    Question;

    Is it possible for when a user goes to example . com to redirect to www . example . com ?

    Thanks again!
     
    cedricd, Nov 6, 2008 IP
  5. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #5
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^DOMAIN\.com [NC]
    RewriteRule ^(.*)$ http://www.DOMAIN.com/$1 [R=301,L]
     
    Nintendo, Nov 7, 2008 IP
  6. cedricd

    cedricd Active Member

    Messages:
    10
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    88
    #6
    Thanks again!
     
    cedricd, Nov 7, 2008 IP