I am trying to write .htacess file that would catch urls like:
http://www.site.com/pageone.html
http://www.site.com/pagetwo.html
and redirect them to index.php so it would receive 'pageone' and 'pagetwo' as GET parameters.
Below is my htacess:
Options +FollowSymlinks
AuthUserFile /dev/null
AuthGroupFile /dev/null
RewriteEngine On
RewriteOptions inherit
RewriteRule ^((?:.[^/])+).html$ index.php?page=$1 [L]
AddHandler php5-script .php
The problem with this regexp is that it catches some pages while showing 404 error on others. And i don't understand this behavior.
For example
works fine. I get 'draw' as GET parameter in my script.
But
http://www.site.com/draws.html
redirects to 404 page
Could anyone explain what is wrong with my htacess ?
p.s. - i am seeing this on a local Apache server under typical MAMP config.
^
= anchor at the start of the URI(?:
= extended expression to group without creating a backreference; unsure what the purpose is here..
= match a single character.[^/]
= match anything that's not a slash+
= all of the above, repeated one or more times.html
= must end in .html$
= anchor the end of the URI.This code would match, among other things, /ab/cd/ef/foo.html, which will never occur in a per-directory context.
It would not match odd-length resources or directories, since you explicitly ignore those with
(.[^/])
.Since you don't specify if multiple subdirectories should be handled or not, just matching what you described can be done much, much easier with:
For further help with troubleshooting, see the RewriteLog documentation