Jump to content

Archived

This topic is now archived and is closed to further replies.

brittny85

Mod_rewrite: working with voodoo

Recommended Posts

The more I try to work with this the more I agree with what it says at the beginning of the Apache manual mod_rewrite article about it being voodoo- cool voodoo- but still voodoo.  I thought I understood it, but since it isn't working, I must not be as close as I thought.  I'm trying to transfer a website from mostly being .htm files to being to all being .php files.  After looking at lots of different docs I came up with this for my .htaccess file:
[code]LoadModule rewrite_module modules/mod_rewrite.so
AddModule mod_rewrite.c
Options +FollowSymLinks

RewriteEngine on
RewriteRule ^.+(\.htm)$ $.php [R=301,L] [/code]

For awhile I somehow had it so that it would redirect all of my .css files to .php (that was fun... not) but it never seems to do the same thing for the only file type that I thought I was specifying- .htm.  Any help would be greatly appreciated!

Thanks!
-Brittny

Share this post


Link to post
Share on other sites
Why don't you just parse the htm files for PHP and leave the URLs as they are?

[code]AddHandler application/x-httpd-php htm[/code]

You might need to adapt this slightly depending on your server config.

Remember that [url=http://www.w3.org/Provider/Style/URI]Cool URIs Don't Change[/url] ;)

Or, failing that, something like the below would probably do the trick:

[code]RewriteRule (.*).htm$ /$1.php[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.