Reputation: 3345
I'm trying to set up some pretty URLs so
http://www.foo.com/results/2014
calls
http://www.foo.com/results/index.php?year=2014
Where '2014' could really be any string (and I will do the appropriate error-handling should I get inappropriate input).
What I'm getting, however, is that http://www.foo.com/results/
works fine but anything after the trailing slash returns a 404 error.
Below are the contents of my .htaccess file. Could someone please point out my error?
Thanks in advance!
.htaccess
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.foo.com/results/$1 [L,R=301]
RewriteRule ^results/([^/]+)/?$ /results/index.php?year=$1
Upvotes: 1
Views: 21
Reputation: 784898
Have it this way inside /results/
directory:
RewriteEngine On
RewriteBase /results/
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]
RewriteRule ^([^/.]+)/?$ index.php?year=$1 [L,QSA]
Reason why your rule didn't work:
results/
folder and URI is /results/foo
then matched URI will be foo
in RewriteRule
RewriteBase
Upvotes: 1