Domain Manage

htaccess help >< please

Discussion in 'Scripts and Coding' started by killaclown, May 18, 2013.

Thread Status:
Not open for further replies.
  1. killaclown

    killaclown Active Member

    Joined:
    Feb 2006
    Posts:
    311
    Likes Received:
    7
    Hi,

    I know its late and im a bit tired, but this shouldn't be problem. I've got mind freeze.

    I cant seem to get my .htaccess file right

    Im trying to write

    /fish[type].php

    eg

    /fishcarp.php

    Code:
    RewriteEngine On
    RewriteRule ^fish([^/]*)\.html$ /fish-page.php?type=$1
    this works

    /fishcarp.html

    but but not this

    Code:
    RewriteEngine On
    RewriteRule ^fish([^/]*)\.php$ /fish-page.php?type=$1
    for /fishcarp.php

    I was thinking if it was a server i'm missing. Any ideas??
     
  2. Domain Forum

    Acorn Domains Elite Member

    Joined:
    1999
    Messages:
    Many
    Likes Received:
    Lots
     
  3. Skinner

    Skinner Well-Known Member

    Joined:
    Jul 2008
    Posts:
    4,325
    Likes Received:
    81
    You may be better using something like


    RewriteRule ^fish([a-z]+).php$ fish.php?fish=$1 [NC,L,QSA]
     
  4. killaclown

    killaclown Active Member

    Joined:
    Feb 2006
    Posts:
    311
    Likes Received:
    7
    hi,

    thats great.

    do you know how I would make it work for more than one page?


    I tried

    Code:
    RewriteRule ^fish([a-z]+).php$ fish.php?fish=$1 [NC, QSA] 
    RewriteRule ^food([a-z]+).php$ food.php?fish=$1 [NC,QSA]
    RewriteRule ^lifespan([a-z]+).php$ lifespan.php?fish=$1 [NC,L,QSA]
    but its not working.

    Any Ideas?
     
  5. Skinner

    Skinner Well-Known Member

    Joined:
    Jul 2008
    Posts:
    4,325
    Likes Received:
    81
    You need to intercept the variable in the above rewrites its going to $_GET["fish"] in php, so you need to make sure each script is accepting that.

    Also you need 3 files fish.php/food.php/lifespan.php which are accepting the fish variable, there is no other reason it wouldn't work.
     
  6. killaclown

    killaclown Active Member

    Joined:
    Feb 2006
    Posts:
    311
    Likes Received:
    7
    Yeah I've done this many times before and never had this problem though. Thanks for your help Skinner. I'm thinking something is different on the server I'm using. Going to test on another server later.

    Thanks again.
     
  7. Skinner

    Skinner Well-Known Member

    Joined:
    Jul 2008
    Posts:
    4,325
    Likes Received:
    81
    I just added

    RewriteRule ^fish([a-z]+).php$ fish.php?fish=$1 [NC,L,QSA]
    RewriteRule ^pie([a-z]+).php$ pie.php?fish=$1 [NC,L,QSA]
    RewriteRule ^recipe([a-z]+).php$ recipe.php?fish=$1 [NC,L,QSA]

    and having just

    <?php echo $_GET['fish']; ?>

    in the 3 files, it works fine.

    must be something server related.
     
  8. killaclown

    killaclown Active Member

    Joined:
    Feb 2006
    Posts:
    311
    Likes Received:
    7
    Thanks skinner, that now works.

    Think i'm cracking up.

    I cant see the original problem, but just gald its sorted.

    Thank you ver very much : )
     
Thread Status:
Not open for further replies.

Share This Page