26 posts
  • Has referred 1+ members
  • Has sold $10,000+ on Envato Market
  • Has collected 100+ items on Envato Market
  • Sells items exclusively on Envato Market
+1 more
incrediblebytes says

Hi everyone :) Just wondering how is it better to implement pretty urls in PHP projects.

What would be optimal or best way to make a feature in a CMS so people can choose if they want to use pretty urls or not.

Shall I use a function for each URL ?

For example:

define("BASE_URL", "http://www.someproject.com/");
define("REWRITE", true);

# Array of url get params (parameter => value)
$postView = array(
    "post" => "some-post-title" 

echo url(BASE_URL, "view.php",  $postView, REWRITE);

And url() function will then build a url either like: http://www.someproject.com/view/post/some-post-title (if REWRITE is true) or http://www.someproject.com/view.php?post=some-post-title (if REWRITE is false)

Just interested what do you use? Maybe someone has got a lot of experience with this?

Thanks in advance :)