Very easy and simple .htaccess & PHP tutorial



If you work with PHP, you notice that this URL: http://yoursite.com/index.php?post=2 is not pretty at all. There is term “Pretty URL” and a lot of tutorials how to make your URL prettier. In this post I’m going to share a few line of .htaccess codes to make your URL more prettier.

Let’s go back to that URL. Here is the goal, we want to make a fake URL like this: http://yoursite.com/post/2/ that redirects us behind the scene to that ugly URL (http://yoursite.com/index.php?post=2).

Here is what we need to add to our .htaccess file:

Read this post to know how to create an .htaccess file: http://zofiakreasi.com/htaccess-tutorial-removing-php-extension/

$1 in that code is a variable. So if a user opens this URL: http://yoursite.com/post/110/ then the value of $1 is number 110.



Published by

Habibie

Habibie is an Indonesian freelance frontend-backend web developer and cross platform mobile app programmer. He's also good at graphics design, video editing, visual effects and animation.

Leave a Reply

Your email address will not be published. Required fields are marked *