I’d be a big fan of getting rid of the current .htaccess method to manage friendly URLs. It seems like there is an easier way to manage this via an internal module that intercepts requests and rewrites them based on pre-defined rules. This way both access and error pages could be logged properly and arbitrary re-writing rules are possible.
Thoughts?
Sounds great but I have very little rewrite skills son can’t contribute there at all.
With the new events will it indeed be possible to activate a plugin/module to handle url rewrites
Victor,
We don’t have an event for the Rewrite URL as yet but you can still go ahead and test it as you would a normal PHP app.
See here for a plugin example:
http://www.modxcms.com/plugin-examples.html
Ryan you might want to sen Victor a copy of the developer’s guide so he can have a list of the events.
Hey! That’s cool. In fact I think the Page-Not-Found Redirector is sort of what you need. The logic works something like this:
- URL request for /foo/bar
- The plugin looks in the internal registry of friendly URLS, and figures out which page is "really" being requested.
- Then that page is rendered and sent back to the browser with a 200 status. Apache logs it as an access on that page
- If there’s no such mapping, then the plug in sends back a 404 status, Apache logs an error
I think the hard part is already done btw -- you’re already maintaining a mapping of page names to friendly URLS. Expose that to this plug in and you’re in business.
-
MODX Staff
- 10,725 Posts
I don’t think we should mess with the friendly URL stuff yet, and mod_rewrite is absolutely the best place to do this now. I honestly can’t even conceive of a proper way to do it without mod_rewrite, because it’s the only way to get everything through one index.php file when no other physical files exist on the server. Otherwise, the webserver could never get the request to MODx...or am I missing something? (i.e. who’s handling the request for /foo/bar/ and how does it know to handle it?)