mod_rewrite /dir1/file1.html -> /index.php?=file1

Discussion in 'Apache' started by screamfine, Sep 21, 2007.

  1. #1
    screamfine, Sep 21, 2007 IP
  2. VimF

    VimF Well-Known Member

    Messages:
    307
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    118
    #2
    Options +FollowSymLinks
    RewriteEngine On
    RewriteRule ^dir1/([a-z0-9_-]*)\.html$ /index.php?id=$1 [L,NC]

    For more, you can use a small tool I wrote the other day:
    htaccess generator
     
    VimF, Sep 21, 2007 IP
  3. screamfine

    screamfine Guest

    Messages:
    114
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks but the problem is that the images are not shown anymore because of the wrong path!? Any solution for this?
     
    screamfine, Sep 25, 2007 IP
  4. intoex

    intoex Peon

    Messages:
    414
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #4
    use absolute paths
     
    intoex, Sep 25, 2007 IP
  5. screamfine

    screamfine Guest

    Messages:
    114
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    screamfine, Sep 25, 2007 IP
  6. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #6
    You have toi edit the links to point to the new URLs. With images, the img code has to be as if the fake URLs are real URLs. Browsers don't know the URLs are fake.
     
    Nintendo, Sep 25, 2007 IP
  7. screamfine

    screamfine Guest

    Messages:
    114
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    screamfine, Oct 2, 2007 IP
  8. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #8
    domain.com/.htaccess

    Options +FollowSymLinks +Indexes
    RewriteEngine on
    RewriteBase /
    RewriteRule ^dir1/([^.]+)\.html$ index.php?id=$1 [L]

    er, I would just keep the fake directory out!!!
     
    Nintendo, Oct 2, 2007 IP