Forum Moderators: phranque
RewriteEngine on
RewriteRule ^([0-9]+)$ index.html?number=$1
No matching DirectoryIndex (index.html,index.cgi,index.pl,index.php,index.xhtml,index.htm) found, and server-generated directory index forbidden by Options directive
init rewrite engine with requested uri /1234
applying pattern '^/([0-9]+)$' to uri '/1234'
rewrite '/1234' -> 'index.html?number=1234'
split uri=index.html?number=1234 -> uri=index.html, args=number=1234
local path result: index.html
I needed the forward slash on the rule as well as the match:Now, wait. That can't possibly be right. mod_rewrite in a directory context (whether htaccess or a <Directory> section of config) does not match against the opening slash. The only exception is if you’ve got this rule lying loose in your config file, which would be exceedingly unusual.
What other, subsequent RewriteRules are there? At a minimum, does this rule come after all external redirects?
I know you are right about not needing the leading slash, but the reason I got confused was that this uses them:
[httpd.apache.org...]
any idea why?
ATTENTION: Depending on your server-configuration it can be necessary to slightly change the examples for your situation, e.g. [...] rewriting a ruleset to fit in .htaccess context instead of per-server context. Always try to understand what a particular ruleset really does before you use it. It avoid problems.
I could not find the 2.4 version of that.