home projects speaker

mod_rewrite made easy

Lately I have been trying to make all my links to look so pretty that even art critics could say something nice about them, and to make it easier for visitors to remember my links. And believe me, it is actually easier than it seems.

How? Well, the solution to this problem was the use of mod_rewrite.

I am not going to explain to you what it is in depth, but basically, it rewrites URI's and also makes it easier for search engines to find your pages. A little tutorial follows.

Instead of using long useless links like:

uri
https://www.phun-ky.net/showpost.php?year=2006&month=08&slug=mod_rewrite_easy

You can make it look so much better with mod_rewrite, like this:

uri
https://phun-ky.net/2006/08/mod_rewrite_easy

Just by adding these lines in a .htaccess-file:

apacheconf
RewriteEngine On
RewriteRule ([0-9]+)/([0-9]+)/(.*)$ showpost.php?year=$1&month=$2&slug=$3
Options +FollowSymlinks
RewriteCond %{http_host} ^www\.phun-ky\.net [nc]
RewriteRule ^(.*)$ https://phun-ky.net/$1 [r=301,nc,L]

If this was hard or you want to learn more, check out the cheat sheet posted with this post or read this .htaccess tips and tricks.


About the author

Hi! My name is Alexander, and I am a creative frontender, specializing in UX, accessibility, universal design, frontend-architecture, node and design systems. I am passionate with open source projects and love to dabble with new emerging technologies related to frontend. With over 26 years of frontend experience, I have earned the right to be called a veteran. I am a lover of life, technologist at heart. If I am not coding, I am cooking and I love whisky and cigars. Oh, and coffee, I LOVE coffee!

If you want to know more about me, here is some links you might want to check out: GitHub, Instagram, Twitter, LinkedIn, CodePen, Slides.com, npm,

Speaker

I am also an avid speaker on several topics! Check out some of the things I speak about, and contact me if you are interested in having me at your next event!