I'll start with an example.
An image with an embedded watermark URL example.com/1203020202
, in the lower right-hand corner in small text will serve as a redirect to the original URL. So when a user visits example.com/1203020202
, they will be redirected to the original URL if it still exists i.e. example.com/something/this-is-the-image-page
. This is so when images are sent via email or shared, found on google images, it serves as a URL shortener and 301 redirects the user to the original source.
EE 2.8 has the new template routing. I'm wondering if it would be better to write an module/extension hook that would do the routing before template parsing. I speculate that this will require more work, but not sure if it's worth it in the end. Does the entry exist, is the status open or closed? etc, etc.
Another option is to use the EE 2.8 routing with a template that would find the entry_id and perform the redirect if {segment:id}
is found.
One thing that scares me about the EE2.8 routing is that seems limited by priority, and correct me if I'm wrong, there is no way to set priority with routing. Edit, as of EE2.9 you can set template routing priorities
I'm thinking of speed overall, and if it can be done before the template parser begins, it's faster, less code, that would be cool.
Any ideas?
example.com/i/1203020202
?segment_1
, you gonna have to search all pages every time somebody try to open something different from the homepage, before look for an image. Then, you can't use a route starting with a variablesegment
, because this can cause conflicts. Let's say, somebody tries to save a page as a number! If you use one single static segment, you can make everything easier. Even better, you can set two different domains on the same directory of the server, one of them being the short version: exp.com/i/1203020202.