Need help with .htaccess on custom site

Discussion in 'Apache' started by Biron, Mar 11, 2008.

  1. #1
    I'm looking to simplify my .htaccess a bit, I know there's prob a couple lines I could use instead of rewriting the main pages manually but I can't seem to get it to fully work, the way I got works perfect now, but would like it written the right way, lol.

    Current .htaccess
    Options -Indexes
    
    RewriteEngine on
    RewriteCond %{http_host} ^racecarracinggames.com [nc]
    RewriteRule ^(.*)$ http://www.racecarracinggames.com/$1 [r=301,nc]
    RewriteRule ^index\.html$ index.php [L]
    RewriteRule ^index2\.html$ pages/index2.php
    RewriteRule ^index3\.html$ pages/index3.php
    RewriteRule ^index4\.html$ pages/index4.php
    RewriteRule ^links\.html$ pages/links.html
    RewriteRule ^links2\.html$ pages/links2.html
    RewriteRule ^links3\.html$ pages/links3.html
    RewriteRule ^([_A-Za-z0-9-]+).html/?$ play/$1.php
    Code (markup):

    What I Tried Using, but only worked for half the pages, rest show 404 error
    Options -Indexes
    
    RewriteEngine on
    RewriteCond %{http_host} ^racecarracinggames.com [nc]
    RewriteRule ^(.*)$ http://www.racecarracinggames.com/$1 [r=301,nc]
    RewriteRule ^index\.html$ index.php [L]
    RewriteRule ^([_A-Za-z0-9-]+).html/?$ pages/$1.php
    RewriteRule ^([_A-Za-z0-9-]+).html/?$ play/$1.php
    Code (markup):
     
    Biron, Mar 11, 2008 IP
  2. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #2
    Keep it simple: ([^.]+)
     
    Nintendo, Mar 11, 2008 IP
  3. Biron

    Biron Banned

    Messages:
    341
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Can't seem to get anything working using that :S
     
    Biron, Mar 16, 2008 IP
  4. Biron

    Biron Banned

    Messages:
    341
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I will pay someone if they can rewrite this to clean it up the best it can.
     
    Biron, Mar 16, 2008 IP
  5. joebert

    joebert Well-Known Member

    Messages:
    2,150
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    145
    #5
    It should scale with index|links 1-N & [L] is used to keep the last few rules from being evaluated when they don't need to be.

    Options -Indexes
    
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^racecarracinggames [NC]
    RewriteRule ^(.*)$ http://www.racecarracinggames.com/$1 [R=301]
    RewriteRule ^(index[0-9]*)\.html$ pages/$1.php [L,NC]
    RewriteRule ^(links[0-9]*)\.html$ pages/$1.html [L,NC]
    RewriteRule ^([_a-z0-9-]+).html/?$ play/$1.php [NC]
    Code (markup):
    If this works for you shoot me a PM & I'll reply with a Paypal link you can do whatever you want with.
     
    joebert, Mar 16, 2008 IP
  6. Biron

    Biron Banned

    Messages:
    341
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #6
    That's awesome, that worked great. I PM'd ya.
     
    Biron, Mar 16, 2008 IP
  7. joebert

    joebert Well-Known Member

    Messages:
    2,150
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    145
    #7
    Pleasure doing business with you.
     
    joebert, Mar 16, 2008 IP