Showing posts with label mod_rewrite. Show all posts
Showing posts with label mod_rewrite. Show all posts

Monday, April 02, 2012

Part 1: SEO-friendly links using .htaccess and PHP

0 comments
A few weeks ago, I decided to try out some URL rewriting to use for some SEO-friendly links. I decided upon using Apache's mod_rewrite in an .htaccess file since I was developing using PHP on Apache. I wanted to be able to use SEO-friendly links on my website. In my solution, the key was using the .htaccess file to rewrite SEO-friendly links in the background back to the ugly URLs and using PHP to write the URLs to the SEO-friendly version for users and the browser to see.

Problem: I needed a way to convert my URLs to SEO-friendly versions.

Impact: The links are hard to remember and not very good for SEO.

Solution:
I used mod_rewrite and an .htaccess file to re-interpret SEO-friendly links back to their original formats.

As an example, the original format was something like:

http://www.example.com/index.php?page=a&id=256&title=my-title

The desired SEO-friendly format is:

http://www.example.com/a/256/my-title