Help - Search - Members - Calendar
Full Version: Convert MT to PHP?
Movable Type Community Forum > Additional Resources > Tips and Tricks
idburns
It seems that quite a few bloggers are converting their MT installs to PHP?  Why?

Is it simply to get the added functionality of PHP?

Is it hard to do?  How do I go about doing it?

Thanks.
jedro
Yes, it is quite simple - although make sure your server has php installed before you do this.

But is should all be covered in this thread.
idburns
None of the links in that thread are working for me.
almuhajabah
Unfortunately, awhile back there was some reorganization of the forums here and links to other threads that were posted before that time no longer work right. The best thing to do is to search the forums for the keyword "PHP".
almuhajabah
P.S. I'm thinking of converting some of my pages to PHP too, because there are some cool things you can do with PHP to add more features to a blog.
jedro
Yeah, I forgot about the forum reorganisation. Search for converting to php in the Tips and Tricks forum and it should be among the first couple of results returned. But basically converting to php is a simple matter of changing your file extensions from html to php.
nammer
As one of the people responsible for keeping this PHP thread alive with my questions, I can say that converting is easy and adds functionality to your site.  If your host offers PHP, it's as simple as changing your output file extensions [for main index, archives, etc.], rebuilding, and deleting your index.html page so that your server defaults to index.php.

Once that's done, you're done, unless you also want to delete the old .html files (in your archives folder for instance) which will duplicate newer files with the same content and the .php extension.  If you do that, you might want to consider creating a custom 404 page to explain what's going on to those who follow broken links in, and give them a hint as to what to do next. See mine in action here.

I find working with PHP to add features and includes to be easier to understand than SSI, and there seem to be a lot of cool PHP things available.  Hope this helps!
idburns
QUOTE
If your host offers PHP, it's as simple as changing your output file extensions [for main index, archives, etc.], rebuilding, and deleting your index.html page so that your server defaults to index.php.

Once that's done, you're done, unless you also want to delete the old .html files (in your archives folder for instance) which will duplicate newer files with the same content and the .php extension.  If you do that, you might want to consider creating a custom 404 page to explain what's going on to those who follow broken links in, and give them a hint as to what to do next.

That's it?  Just go through and change all the output files to .php and then rebuild?

It seems too easy...  :0

Also, since all my MT links are generate dynamically I shouldn't have to worry about the 404 page, unless someone has something bookmarked right?

Maybe I'll create another blog that will be my guinea pig...
idburns
I think I did it on my test.  Does this look right?

http://www.hostileterritory.org/test/
kadyellebee
You are correct about your links all automatically updating smile.gif  When I view your test page, its different looking than if I view
http://www.hostileterritory.org/test/index.php
So you'll need to go into your FTP program in that directory and delete index.html so that people go automatically to the .php file instead (most hosts have it setup to go to index.html and if there isn't an index.html, go to index.php smile.gif )

Hope that helps,
Kristine
maddy
About not explaining in your 404 page, if you've ever linked to your own entries within your own posts, you might also like to do a search of your entries and point these to your new pages. I did that eventually, but for a start it was easier to just tell people getting a 404 what was going on and to switch extensions themselves. I still get the occasional hit from a googler wanting one of my html pages. ohmy.gif
idburns
I did another of my blogs - http://www.hostileterritory.org/jetteye

I guess the next one is my main blog at http://www.hostileterritory.org

I imagine upgrading to new MT releases shouldn't have any effect on this should it?  It doesn't seem that it would.
idburns
I have all my blogs converted.   smile.gif
gabbro
One step better than a custom 404 page is using mod_rewrite to send all requests for the old html file to the new php page, automagically (if your server is set up for it).

There's a lengthy users' guide to mod_rewrite but to change the suffix on your URLs you just need one quick line. I have the following rule in my .htaccess file:
CODE
RedirectMatch (.*)\.shtml$ http://greengabbro.net$1.php

It works like a charm.

I've found the worst part about switching to php is that I keep fiddling with it... I've added entirely too many features that no one notices or cares for. biggrin.gif
almuhajabah
gabbro - Thanks for the suggestion! That sounds like the perfect way to handle it. I will try implementing this solution.

I found an excellent introduction to the basics of Apache redirects. If all you want is to redirect requests for foo.htm to foo.php it's easier to use this guide than to wade through the entire mod_rewrite documentation.
almuhajabah
gabbro - I just want to say thanks again for posting your tip. I finally converted my blog pages to have a .php extension and used the RedirectMatch command in my .htaccess files to deal with the problem of broken links. It can't get much simpler than this and it works great!!
nammer
QUOTE
I have the following rule in my .htaccess file:
CODE
RedirectMatch (.*)\.shtml$ http://greengabbro.net$1.php

It works like a charm.

This is excellent, gabbro!  I have one silly question - I worked so hard to get my domain to default to index.php - all you have to do is type in deliriouscool.org and you're there.  But the redirect defaults even my index page to the full address (deliriouscool.org/index.php)?  I love the automatic redirect for archives, but I like my front page plain vanilla.  Should I care?  Probably not if I like the automatic redirect, huh? I'm so picky!  :p
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.