Emulate single application entry point with .htaccess

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

User avatar
allspiritseve
DevNet Resident
Posts: 1174
Joined: Thu Mar 06, 2008 8:23 am
Location: Ann Arbor, MI (USA)

Re: Emulate single application entry point with .htaccess

Post by allspiritseve »

Right... I guess I can't see that working if the links are so varied that you can't search and replace.
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: Emulate single application entry point with .htaccess

Post by alex.barylski »

Right... I guess I can't see that working if the links are so varied that you can't search and replace.
Haha...welcome to my world? :P

The only solution would be to find links...parse them into name=value pairs and handle it that way so at least the order of the NVP's wouldn't matter. It's a serious PITA and easily avoidable with proper design -- unfortunately this site missed a few steps during design phase -- which is typical for first version prototypes I suppose.
User avatar
allspiritseve
DevNet Resident
Posts: 1174
Joined: Thu Mar 06, 2008 8:23 am
Location: Ann Arbor, MI (USA)

Re: Emulate single application entry point with .htaccess

Post by allspiritseve »

Believe me, I hear you... At least I'm lucky (depends on your perspective) enough to work for a small company with a small codebase that doesn't take too long to fix all those mistakes. The hard thing is they have been using the latest project as the "codebase" for the last 6 years and so have left behind a trail of incrementally-updated versions of our codebase. Which means come time to do updates, I've got to make the same fixes over and over again. Blah

I've been thinking about your situation a bit more... if you did parse for key/value pairs like you mentioned, could you do some logic to spit out clean urls based on what keys are set? maybe you could write a script that could search and replace, for example, all links from help.php with id and name set to /help/name/id/, and so on? You've accounted for order, so now it's really just figuring out the types of urls needed. That is, unless whoever wrote your code writes like my boss and throws a couple extra fields in the url just for the hell of it. :)
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: Emulate single application entry point with .htaccess

Post by Benjamin »

Hmm, well the same function that converts the links at runtime could be used as a find/replace tool. You could write a tiny script to open each file, convert the links, then save it.
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: Emulate single application entry point with .htaccess

Post by josh »

Subclass Zend dispatcher for your page controller paradigm?
Post Reply