Wednesday, June 20, 2007

Changing file extensions

When we moved the main site from JSP to PHP, we wanted to make sure that if people had old links, they would still work.
To this end, most of the pages ended up with the same filenames, the only change was the extension. Initially there was a mod_rewrite rule created that would push all people going to *.do to *.php. For some reason it stopped working. No clue why?

My experience with mod rewrite is extremely limited. I'm happy to say I'm somewhat baffled by regular expressions. It takes me an inordinate amount of time to write them.

As an interim solution, I updated the conf so that *.do would be executed as *.php. Almost all of the requests for .do pages were for one particular page, so now we have two copies of the same page. Not an ideal solution by far, but at least they aren't getting 404's anymore.

In my efforts to try and fix this problem, we decided to make some changes to our 404. Previously it simply redirected to the homepage, as we didn't have time to work out what we really wanted it to do. I updated so the 404 is a php page, and I check the URI and redirect the user to the search page, with what they request as a search query. It's quite slick, and handles proper movie names.

For a sneak peek (not live yet) try one of our movie or tv show names after the following url: http://vendor.mgm.com/movie name Unfortunately it doesn't handle the "lack" of spaces yet. That's going to be handled once my new DB design is implemented.

http://vendor.mgm.com/rescue dawn or http://vendor.mgm.com/stargate atlantis

BFN

No comments: