Reputation: 295
I currently have this line in my htaccess:
RewriteRule ^/events/([^/\.]+)/?$/ /events.php?eventdate=$1 [NC,L]
I have a php page events.php that is pulled dynamic dates and generating the content. When people go to /events/04-26-2013/ for example I want it to be pulling from events.php?eventdate=04-26-2013
Any ideas where I am going wrong here? It currently gives me a 404 when I try to load the directory.
Upvotes: 1
Views: 97
Reputation: 7880
According to the RewriteRule Directive setion of the mod_rewrite manual :
In VirtualHost context, The Pattern will initially be matched against the part of the URL after the hostname and port, and before the query string (e.g. "/app1/index.html").
In Directory and htaccess context, the Pattern will initially be matched against the filesystem path, after removing the prefix that led the server to the current RewriteRule (e.g. "app1/index.html" or "index.html" depending on where the directives are defined).
If you wish to match against the hostname, port, or query string, use a RewriteCond with the %{HTTP_HOST}, %{SERVER_PORT}, or %{QUERY_STRING} variables respectively.
Unless there is a good reason for serving pages from /EVENTS/,/Events/,& /events/ you do not need the [NC] No Case
declaration. So for .htaccess the rule looks like this:
RewriteRule ^events/([^/\.]+)/?$ events.php?eventdate=$1 [L]
In the VirtualHost context it would look like this:
RewriteRule ^/events/([^/\.]+)/?$ /events.php?eventdate=$1
Upvotes: 0
Reputation: 14776
I believe your problem is with your first slash.
This should work.
RewriteRule ^events/([^/\.]+)/?$ /events.php?eventdate=$1 [NC,L]
Upvotes: 2