I am writting my own small framework and I am going to implement friendly URLs there. mod_rewrite is great. But I want to be able to handle several types of friendly URLS at once:
/index.php?ac=user&an=showprofile (fallback variant, the worst)
/index.php/user/showprofile (supposedly, can be disabled by security settings)
index.php?user/showprofile (optional, not needed)
/user/showprofile (ideal, but requires mod_rewrite or dirty ErrorDocument tricks)
I would like all the variants to be supported at once so that old links generated with whatever scheme would be forever valid. Should I write my own parse functions for this or, may be, I missed some library/script, that can do that? Extracting algos from big frameworks like Symfony or Zend is quite difficult. There are also many different unobvious cases like correctl handling URLs UTF-8 encoded or with magic_quotes_runtime etc…
If you can both programmatically distinguish between all different types of URLs and normalize them to one base form you can just write a simple tokenizer function that normalizes the different types and you can use the normalized type to get the actual destination. I’ve done this, but not without mod_rewrite. Pretty sure it can be done without it though.
I usually have one index file that parses whatever url and then does a bunch of request handling and routing to get the output, without having any url map directly to any file. Just mod_rewrite everything to that index file and parse
$_SERVER['REQUEST_URI'].