Mod Rewrite Question

Discussion in 'Apache' started by Darkhodge, Jun 28, 2006.

  1. #1
    Hi,

    I just tried implementing a mod rewrite on my website but for some reason it doesn't seem to be having any effect... I'm quite new to all this stuff (only used to html) so please bare with me...

    Here's the code I used:

    I saved this in my "public_html" as ".htaccess" and yet all my URLs are displaying exactly as they were before...

    Have I made some stupid mistake somewhere? :eek:


    Thanks in advance
     
    Darkhodge, Jun 28, 2006 IP
  2. forumposters

    forumposters Peon

    Messages:
    270
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #2
    The mod rewrite does not change your urls. Those need to be changed as well. The mod rewrite will only make the static urls work. You're halfway done, now just go through and hardcode your urls to change them from dynamic to static. You're not stupid - I had this same confusion when I first tried this as well.
     
    forumposters, Jun 28, 2006 IP
  3. abuzant

    abuzant Well-Known Member

    Messages:
    956
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    140
    #3
    Also,

    
    RewriteRule ^pages/guitar\-tabs/(.*)\.html$ pages/guitar-tabs/tab-category.php?category=$1 [L]
    RewriteRule ^pages/guitar\-tabs/(.*)/(.*)\.html$ artist-tab-list.php?category=$1&artistName=$2 [L]
    
    PHP:
    instead of

    
    RewriteRule ^pages/guitar\-tabs/(.*).\html$ pages/guitar-tabs/tab-category.php?category=$1 [L]
    RewriteRule ^pages/guitar\-tabs/(.*)/(.*).\html$ artist-tab-list.php?category=$1&artistName=$2 [L]
    
    PHP:
     
    abuzant, Jun 28, 2006 IP
  4. Darkhodge

    Darkhodge Well-Known Member

    Messages:
    2,111
    Likes Received:
    76
    Best Answers:
    1
    Trophy Points:
    185
    #4
    abuzant -> Lol - thanks for spotting that mistake. That was the stupid part I was talking about :D

    forumposters -> Thanks - I understand what the mod rewrite does now :)
     
    Darkhodge, Jun 29, 2006 IP
  5. abuzant

    abuzant Well-Known Member

    Messages:
    956
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    140
    #5
    Hey no problem, im in bed with mod_rewrite more than my wife :D
     
    abuzant, Jun 29, 2006 IP
  6. Darkhodge

    Darkhodge Well-Known Member

    Messages:
    2,111
    Likes Received:
    76
    Best Answers:
    1
    Trophy Points:
    185
    #6
    Just a quick question - I use the following code to collect all the names of the files that have the extension ".gp3" or ".gp4" into an array.

    Is there a function that allows me to order the array alphabetically?

    
    $dp = openDir ("$category/$artistName");
    while ($currentFile !== false){
      $currentFile = readDir ($dp);
      $tabs [] = $currentFile;
    }
    $tabs = preg_grep ("/gp3$|gp4$/" , $tabs);
    
    PHP:
     
    Darkhodge, Jun 29, 2006 IP