I’m trying to alter the way we currently provide a gateway page system within our CMS. What i mean by gateway page is mapping a non-existent URL to a page through a rewrite rule in the .htaccess, e.g.
RewriteRule ^foobar$ page.php?mode=bar&method=foo&id=1
This allows people to create short links to CMS pages for magazine adverts etc. The problem with this method is that it relies on access to the .htaccess. I would prefer a method that sits at code level but it occurs to me that – without a rewrite rule – a 404 error will be called. Is there any way to prevent this or work around this?
You can use a rewritemap within your htaccess. What this does is references an external file/script, passing it the incoming uri and getting back the rewritten uri.
In your .htaccess
In your php file map.php
The php file is passed the short url and returns – based on your logic – the full url