- This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
Viewing 3 posts - 1 through 3 (of 3 total)
- The forum ‘Back End’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
If you’re at all familiar with CakePHP, you know it can take a value, say, the name of a table, and create a pseudo-directory out of it. For instance, domain.com/users/ would be automatically created if you had a users table. Now, I want to do this on my own outside of CakePHP. I searched the problem and found the main way to do this was use the directory rewrite (mod_rewrite) function in the .htaccess file. I looked through my own .htaccess (with CakePHP installed) and found that CakePHP was not using mod_rewrite, as the file didn’t contain it. So, how does CakePHP create “pseudo-directories” in PHP alone? Thanks.
It’s called Pretty-URLs. A common way for frameworks to handle this is to redirect all traffic to the index.php and then deal with it programmatically.
So the rule within .htaccess redirect everything to index.php which then have it own set of rules. How you define/handle these rules and the resulting redirect/rendering is different from case to case.
This small helper library can help you with Pretty URL’s: https://github.com/codler/Startup
For future searchers:
There are basically two methods to accomplish what I was talking about.
1) .htaccess: http://net.tutsplus.com/tutorials/other/using-htaccess-files-for-pretty-urls/
2) Pure PHP: http://elephantlorry.com/code/php-easy-pretty-urls
Note: it says I do not have permission to mark as solved/edit.