Jump to content

Mod_rewrite: working with voodoo


brittny85

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
Link to comment
Share on other sites

  • 3 weeks later...
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]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.