Forum Moderators: phranque

Message Too Old, No Replies

RewriteRule help for .htm

RewriteRule help for .htm to .php in root only

         

g_bloggs

3:57 pm on Feb 18, 2007 (gmt 0)

10+ Year Member



Hi.

I have the following RewriteRule in my .htaccess:

RewriteRule ^([^.]+)\.htm$ htmhandler.php [L]

It works. The idea being that any file requested in the webserver root ending in .htm will be redirected to the handler file which will do some work. I have *NO* .htm files in webroot so this works how I expect. Problem is it appears to work on *ALL* .htm files in nested directories. I don't tend to use htm files much, and if I do I call them .html so this didn't matter until I wanted to use tinyMCE.

For example it is looking for this file:
/includes/javascript/tiny_mce/themes/advanced/source_editor.htm

But the RewriteRule above is kicking in and sending the request to the htmhandler.

How do I specify to the RewriteRule only to rewrite .htm in webroot?

Thanks

jdMorgan

4:45 pm on Feb 18, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Since any subdirectory path will have to have a slash in it, simply modify the pattern to reject slashes as well:

RewriteRule ^([b][^./][/b]+)\.htm$ htmhandler.php [L]

Jim

g_bloggs

5:03 pm on Feb 18, 2007 (gmt 0)

10+ Year Member



Jim

super star! Thanks. Was still trying to sort this out. Only spent 5 hours :$. But have learnt quite a bit...