brittny85 Posted June 13, 2006 Share Posted June 13, 2006 I am working on converting a site that I made when I only knew HTML to PHP. I want to avoid link rot but I'm not sure what the best way is to go about doing so. It is a relatively large site so if possible I would like to avoid having to write a redirect page for each individual page. Essentially every page that was originally .htm will now be .php so that I can make use of the capabilities of PHP on each page, but with the same filename otherwise. Is there an easy way to go about doing this? I'm trying to think if I can just write a php script on my 404 page that will check if the link they were looking for was .htm and try first to redirect them to a page with the same name but ending in .php, but I don't know how to do that. If the best way is just to put a re-direct link in each individual file, what is the "correct" way to do so? Most of the places I have looked have said to use a META redirect, but I also saw on w3.org that that was a deprecated way of doing so. I don't have access to reconfigure the server. Any suggestions would be very welcome!Thanks!-Brittny Quote Link to comment Share on other sites More sharing options...
nogray Posted June 13, 2006 Share Posted June 13, 2006 you can use mod_rewrite to redirect the .htm pages to .phpJust google it and you'll find tons of tutorials Quote Link to comment Share on other sites More sharing options...
brittny85 Posted July 7, 2006 Author Share Posted July 7, 2006 Thanks! That was really helpful and a good start. But 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. After looking at lots of different docs I came up with this for my .htaccess file:[code]LoadModule rewrite_module modules/mod_rewrite.soAddModule mod_rewrite.cOptions +FollowSymLinks RewriteEngine onRewriteRule ^.+(\.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.Thanks!-Brittny Quote Link to comment Share on other sites More sharing options...
cmgmyr Posted July 10, 2006 Share Posted July 10, 2006 you can also throw this into an .htaccess file[code]AddType application/x-httpd-php .php .htm[/code]this will parse html as php. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.