Jump to content

Recommended Posts

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
Link to comment
https://forums.phpfreaks.com/topic/11895-redirects/
Share on other sites

  • 4 weeks later...
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.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.

Thanks!
-Brittny
Link to comment
https://forums.phpfreaks.com/topic/11895-redirects/#findComment-54590
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.