Error code 400 - Bad Request

Discussion in 'Apache' started by Darkhodge, Sep 13, 2010.

  1. #1
    Hi guys,


    I have an issue I'd love your help with!

    I have a subfolder within my site called "photocomp", as I am hoping to run a photography competition in the near future. I am using mod_rewrite to create clean URLs, however am getting an error code 400 (bad request) when I access the subfolder without the trailing slash ("/").

    My .htaccess is as follows:

    
    Options +Indexes
    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /photocomp/
    
    RewriteRule ^([^\/]*)/([^\.]*)$ view_photo.php?artistSlug=$1&photoSlug=$2 [L]
    RewriteRule ^([^\.]+)$ search.php?search=$1&fromSlug=yes [L]
    
    Code (markup):
    What I want to achieve is basically:

    http://www.example.tld/photocomp/ -> homepage
    http://www.example.tld/photocomp/filename.php -> shows the file.
    http://www.example.tld/photocomp/artist_name -> uses search.php to search for artist.
    http://www.example.tld/photocomp/artist_name/photo_name -> uses view_photo.php to show image.

    Everything seems to be working fine, except for not being able to access the photocomp homepage when the trailing slash is absent.

    When the RewriteRules are removed, then the homepage can be accessed as the server automatically adds the trailing slash.

    Can anyone spot the mistake I've made?


    Thanks,

    Hodge
     
    Darkhodge, Sep 13, 2010 IP