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 :)

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes

by
by
by
by
by
by