Ah, but the link in the html is most likely to /index.html, rather than the full thing.
It will be easiest to add this code in at the point that a FURL is created, as there we have the document ID number that can be compared to site_home.
-
MODX Staff
- 10,725 Posts
The url rewriting is done towards the end of the parsing process, and the only event you could use to alter them is OnWebPagePrerender. But they would already rewritten at that point, so you’d have to replace the already rewritten URLs
Does index.html?start=2 work? Looks like it won’t... Other than that minor matter, great work.
So. You have a goal of turning blog.html?start=2 into blog2.html. Great goal.
Now. Turning the "blog.html?start=2" that a page outputs into "blog2.html" is, in principle, doable with the OnWebPagePrerender. But where is it going to get that replace rule from? There needs to be a list of rules somewhere -either specific (blog.html?start=2 = blog2.html) or generic (blog.html?start=[X] = blog[X].html). I’ll come back to that.
Lets say someone clicks on a blog2.html link.. MODx doesn’t have a page "blog2", so it would 404. We need to run something after the normal MODx document-ID-find routine that will look through the list the other way and find the normal alias and the GET string. Given blog2.html, it needs to set the ID based on "blog" and set various values in $_GET.. then everything should work.
So both of these sides are highly dependent on there being a lookup table for desired SEO overwrites... to me, this seems like a job for a db table that you can add to in a Manager module. This would be quite a cool feature to have. The questions then arise of how far things should be generic / automated. Is it easier/quicker to pregenerate blog2, blog3, blog-august-2006 etc, or to look for rules and build up matches? I think the first step has to be manually entered page overrides.
--
Of course, search engines *will* index blog.html?page=2, but I can see that there is an optimisation benefit. I’ve never personally had much trouble getting non-static pages indexed well; switching a non-generic title (eg product name instead of just shop name) seems to be the best SEO change I’ve ever made to dynamic systems. Indeed, I don’t particularly care if the 2nd page of blog summaries is indexed, as long as the documents it references have been crawled. But there are situations in which replacing dynamic URLs with fake static ones will be good. I’m watching this plugin with keen interest.
I have updated the code again. www.domain.com/?start=2 & www.domain.com/index.html?start=2 should now work. Let me know. www.domain.com/index.html still redirects to base dir. i’m thinking of redirecting www.domain.com/?start=2 to www.domain.com/index.html?start=2.
I am looking into the options for the static urls. That part is a lot more complicated then the rest of the code. It would be easy if it was the core that was being edited but doing it via a plugin is not so simple. I’ll keep the thread updated on it. I’ll probably work on the directory features first.
I also need some more beta testers. I specifically need the following types of tests.
1. Tests on 0.9.2 platforms.
2. Tests with modx installed in a sub directory like www.domain.com/modx_install/
Any takers out there? I have a feeling something will break in both of these.
You can’t do the redirect in the same way in 0.9.2 -
header("HTTP/1.1 301 Moved Permanently");
header('Location: ' . $myDomain);
is a new feature in 0.9.5. So there’s no point testing it in anything prior to that.
Sorry, what I mean is that the ability to use this is new. Prior MODx versions had already set the headers earlier on. Or something.