Why does my .htaccess not work?

Discussion in 'PHP' started by NextToNothing, Mar 9, 2011.

  1. #1
    Hello,
    Can someone please check my .htaccess?
    RewriteEngine on 
    
    #ErrorDocument 400 error.php?e=400
    #ErrorDocument 401 error.php?e=401
    #ErrorDocument 403 error.php?e=403
    #ErrorDocument 404 error.php?e=404
    #ErrorDocument 500 error.php?e=500 
    
    RewriteRule ^([^/]+)(|/)$ view-season.php?show=$1
    RewriteRule ^([^/]+)/season-([^/]+)(|/)$ view-eps.php?show=$1&season=$2
    RewriteRule ^([^/]+)/season-([^/]+)/episode-([^/]+)(|/)$ video.php?show=$1&season=$2&episode=$3
    Code (markup):
    When i goto, for example, http://mysite.com/test/season-1/episode-2/ it will come up with an error, but http://mysite.com/test/ will work, i cant see what im doing wrong and it would really help if someone could check my code over.

    Thanks
     
    NextToNothing, Mar 9, 2011 IP
  2. NLZ13

    NLZ13 Well-Known Member

    Messages:
    166
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    113
    #2
    *Edit*

    Very stupid answer :p

    Do you have an url of your website?
    And i've never seen (|/), what does that do?
     
    NLZ13, Mar 9, 2011 IP
  3. NextToNothing

    NextToNothing Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    its only on my localhost at the moment,
    and (|/) allow the url with or without the /
     
    NextToNothing, Mar 9, 2011 IP
  4. NLZ13

    NLZ13 Well-Known Member

    Messages:
    166
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    113
    #4
    Ok, First thing I can say is better don't use that. Because links with and without the slash would produce the same content (duplicate content, and that is not good for seo).
    Second, does it make any change if you do or don't use the slash at the end of the url
    Third, does it work if you access the view-episode.php and view-eps.php directly
     
    NLZ13, Mar 9, 2011 IP
  5. NextToNothing

    NextToNothing Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    The only reason i used the (|/) tag is because if people are typing it by hand they may miss the end / off or not put it on.
    If i access the files directly they work fine.
    I copyed a line then pasted it and removed the line i copyed at first and now im getting a new error. When i access a page which has the url which another rewrote rule has it seems to be going to the first one specified. So if i goto http://mysite.com/test/season-1/episode-2/ it will come up with the content of http://mysite.com/test/ not http://mysite.com/test/season-1/episode-2/

    ***EDIT***
    Ive fixed it by removing the (|/) on all the rewrite rules, ive just left it so it has to have the ending /
    Thanks for your help.
     
    NextToNothing, Mar 9, 2011 IP
  6. NLZ13

    NLZ13 Well-Known Member

    Messages:
    166
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    113
    #6
    Okay, glad it worked out
     
    NLZ13, Mar 9, 2011 IP