Jump to content


Photo

Redirects


  • Please log in to reply
3 replies to this topic

#1 brittny85

brittny85
  • Members
  • PipPip
  • Member
  • 23 posts
  • LocationUtah

Posted 13 June 2006 - 05:11 PM

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

#2 nogray

nogray
  • Members
  • PipPipPip
  • Advanced Member
  • 930 posts
  • LocationSan Francisco CA

Posted 13 June 2006 - 05:14 PM

you can use mod_rewrite to redirect the .htm pages to .php

Just google it and you'll find tons of tutorials

NoGray.com


#3 brittny85

brittny85
  • Members
  • PipPip
  • Member
  • 23 posts
  • LocationUtah

Posted 07 July 2006 - 10:53 PM

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:
LoadModule rewrite_module modules/mod_rewrite.so
AddModule mod_rewrite.c
Options +FollowSymLinks 

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

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

#4 cmgmyr

cmgmyr
  • Members
  • PipPipPip
  • Advanced Member
  • 1,278 posts
  • LocationUSA

Posted 10 July 2006 - 02:41 AM

you can also throw this into an .htaccess file

AddType application/x-httpd-php .php .htm

this will parse html as php.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users