You are not logged in.
Allow your visitors to use just the article ID in the URL. Optionally output a canonical
<link> tag that uses said short URL too.
Written in response to Sam’s request, using wet’s code.
All available versions and changes are listed here. Each entry indexes the relevant post(s) in the threads to learn about the features.
Last edited by Bloke (2009-10-19 10:25:34)
Killer idea Steph – another timely addition to the toolset.
The only problem I can see with it is that it doesn’t appear to play nicely with gbp_permanent_links (I’m using 1.3) – it just rewrites the URL according to the Txp prefs.
I’m not sure which plugin would need to be updated, but until they’re compatible, smd_short_url is a no go for me.
The only problem I can see with it is that it doesn’t appear to play nicely with gbp_permanent_links
No, you’re right it won’t. It just generates a stock TXP url and forwards the page to that. I guess gbp_permanent_links doesn’t get called again after a redirect. Have you tried putting smd_short_url at a higher priority (e.g 4) so it is called first, thus giving gbp_ a chance to rewrite the url a second time? Long shot, but it might work.
I’ll drop Graeme a line and see if he can tell me the best way to make the plugins play in the same sandpit without throwing sand in each others’ eyes.
Last edited by Bloke (2009-06-18 09:40:52)
Did you try robert’s solution within your error_default page ?
I got a reply from Graeme. Give this a whirl: go into smd_short_url and change the first line to this:
Then see if it works with gbp_permanent_links. Also try adjusting the plugin priorities. It may be that gbp_permanent_links has to be first I don’t know. If any combination of change to plugin code and order of execution works, please let me know so I can supply the option to make it work with gbp_permanent_links.
Also give Pat64’s idea a go. If that works I can try and make the plugin optionally hook into the 404 page as well.
Thanks in advance.
Last edited by Bloke (2009-06-18 15:30:58)
register_callbackdid the trick perfectly
Excellent, thanks for testing. In which case, consider the plugin updated to v0.11
Two things spring to mind:
'textpattern'event will result in approximately 99% energy waste as most requests will not go to any short URL. Thus, I’ve added a ‘txp_die’ event for TXP 4.2.0 which lets you easily intercept
404(and some other) stati and redirect to the canonical URL then:
register_callback('smd_short_url', 'txp_die', 404);
302is the proper HTTP status. Maybe
301would fit better (I know who brought
302onto the table in the first place)
Two things spring to mind <snip>
Fabulous. Thank you very much, sir. I’ll fix the plugin ready for release alongside 4.2.0. In fact, that callback is going to come in very handy for a few other projects I’m working on.
And you’re right about the status code. I should have read up on the difference between 301 and 302 before blindly implementing it. Thanks for the correction.