use Mod_rewrite or trailslashes on uri
i would like to know what is the best option, im re-coding my own simple php framework, i used to have url lik this index.php?mod=gallery&id=1 then i implement mod_rewrite and this look like this gallery/1 but then i found out looking on MVC that you could use trailing slashes on the uri and forgot about GET params and treating url like this index.php/gallery/1.
But, i want to know which one is better to use. GET + Mod rewrite, or trailin slashes. by the way using slashes on th开发者_JS百科e uri i couldnt figure out how to use GET at the same time.
well let me know you experiences or advice.
Thanks.
Using trailing slashes is more portable - your application can easily run on other web server software, like Microsoft IIS, lighttpd, nginx.
On the other side, using mod_rewrite or equivalent makes your URLs prettier and shorter, and to use parameters from trailing slashes version like GET
array, you have to implement your own REQUEST_URI
parser.
If you use this format:
index.php/gallery/1
you won't use $_GET
but you will analyze the requested uri, extracted from the $_SERVER
array in the index.php
file. It doesn't need rewrite configuration, but IMO it looks ugly. I'd go for the clean rewritten version.
精彩评论