apache - .htaccess refinements to rewrite rule which hides .php extension -
apache - .htaccess refinements to rewrite rule which hides .php extension -
last month used rules:
rewriteengine on rewritecond %{request_filename} !-f rewriterule ^([^\.]+)$ $1.php [nc,l] to create site urls nicer , chop off .php urls.
i have found problems above code, works fine intended , nil else, have issue; subfolders, such
www.site.co.uk/horses/ the .htaccess generates 'file not found'
www.site.co.uk/horses/.php as adds .php onto empty string.
i spent quite time reading same examples on , on 1 time again how utilize mod_rewrite examples missed looking for, prevent empty 'not-defined' filename having .php appended it. examples , answers great did hang on same premise reason mod_rewrite turn folder shapes /page/content/variable/variable requests (i generalise).
my solution problem of www.site.co.uk/horses/ not finding index.php file thus: (*follow symlinks on already...)
rewriteengine on rewritecond %{request_filename} !-f rewriterule ^([^\.|/]+)$ $1.php [nc,l] adding "if ending of file not . or / " rule. know it's simple perl regex figure may useful others out there similar problems.
as additional, i've not seen examples of can .htaccess have multiple conditions, and/or multiple rule lines?
also, how come issues not appear base/root directory, address www.site.co.uk/ works, regardless of rewrite rules?
apache .htaccess mod-rewrite filenames
Comments
Post a Comment