I am trying to use a simple Mod Rewrite rule on my test server to take a url from localhost/category-1234.html to localhost/modtest.php?cat_id=1234 using the following .htaccess file (in C:\Program Files\Apache Group\Apache2\htdocs) RewriteEngine On RewriteRule ^category-([0-9]+)\.html$ modtest.php?cat_id=$1 [L] The apache error log shows "script not found or unable to stat " and browser returns 404. In the apache httpd.conf file I have uncommented LoadModule rewrite_module modules/mod_rewrite.so but I can not find an entry for AddModule mod_rewrite.c and if I add it manually then apache will not restart. Any ideas, is this an Apache issue or have I just cocked up the .htaccess entry? Thanks
mod_rewrite works on any hostname. It's one thing to suggest that attempting it on localhost is the issue but going round stating as fact that it does not work on localhost is ridiculous, not to mention entirely inaccurate. I happily test out all my rewrites locally as I'm sure most other people do when building applications that make heavy use of URL rewriting. Just because you haven't setup your local server to have mod_rewrite working does not mean no one else can! A quick search through the official documentation reveals absolutely no mention of issues on localhost. Google search can do no better - yes, people having problems with their configuration but nothing whatsoever to suggest that localhost is the problem. But most of all its common sense - the mod_rewrite module has nothing to do with the hostname. Sure, it's accessable via %{HTTP_HOST} but that's the extent of it, along with every other server variable. Fair enough, you could think it may be an issue but looking into it would quickly prove that's not the case. No offense intended but you really can't constantly continue to try and pass off a completely inaccurate statement as fact simply because you don't know the real answer. I'm sure I've even pointed out this localhost misunderstanding before once or twice but clearly to no avail. @ferret, have you tried checking/setting AllowOverride to All? Other than that, I'm not sure - your .htaccess code looks fine to me.
Had amended apache conf file to look like <Directory /> Options FollowSymLinks AllowOverride All </Directory> as it was set to None, however it is still failing with the same error. Any other ideas cheers
Is that the only instance of AllowOverride? At least on my XAMP setup, the standard httpd.conf first specifies options for the root domain in the <Directory /> tags, then later has it repeated for the webroot, i.e. <Directory D:/xampp/htdocs/>
No, missed the others, have now amended that too but still not working <Directory "C:/Program Files/Apache Group/Apache2/htdocs"> # # Possible values for the Options directive are "None", "All", # or any combination of: # Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews # # Note that "MultiViews" must be named *explicitly* --- "Options All" # doesn't give it to you. # # The Options directive is both complicated and important. Please see # http://httpd.apache.org/docs-2.0/mod/core.html#options # for more information. # Options Indexes FollowSymLinks # # AllowOverride controls what directives may be placed in .htaccess files. # It can be "All", "None", or any combination of the keywords: # Options FileInfo AuthConfig Limit # AllowOverride All # # Controls who can get stuff from this server. # Order allow,deny Allow from all </Directory>