Page is a not externally linkable
- Code, Content, and Presentation
-- Apache Web Server
---- Problem using mod_rewrite / .htaccess in the root directory


jdMorgan - 12:09 am on Feb 18, 2004 (gmt 0)


PhilC,

This should do it, plus bring your regex in line with the objective you posted -- to redirect requests for .html resources in the root directory only. "^.*\.html$" would redirect for any .html file in any directory, while "^[^/.]*\.html$" redirects only if the filename is not preceded by a slash (which would indicate a subdirectory request) or another period (this just makes the regex processing for this case faster).

If you *do* want to redirect .html requests in subdirectories, then you could use "^[^.]*\.html$" or your original "^.*\.html$" shortened to "\.html$". In either case, the parentheses are not needed, since you are not creating a back-reference or a complex nested OR pattern.

RewriteRule ^$¦^[^/.]*\.html$ rewrite.php [T=application/x-httpd-php]

Note that you must replace the broken pipe "¦" character with a solid pipe character from your keyboard before use.

Ref: [etext.lib.virginia.edu...]

Jim


Thread source:: http://www.webmasterworld.com/apache/1094.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com