SEO Friendly URL

I love the way SO gives link to question Like this question have the link http://stackoverflow.com/questions/6002203/seo-friendly-url where the question title is seo-friendly-url

I’m creating a blog where i want to give the link in the same way SO do, how to do that in PHP ?
Any suggestion is welcome 🙂

Table Structure

  • ID
  • Title
  • Tags
  • Category
  • UID

Added
I’m using PHP/APACHE and no framework ! I dont want to use any blog, want to create my own



SEO friendly URL

Which is more seo friendly URL from below http://www.example.com/products/market-reports http://www.example.com/products/market-reports.aspx Can anyone help?

CakePHP friendly seo url

I want to make my url seo friendly. www.example.com/posts/view/1 change for www.example.pl/:slug-:id. Everything works fine, but probably I’m doing something wrong with routing, because when after cli

Joomla SEO Friendly URL Problem

In my current Joomla Project, I set the SEO friendly in URL in global configuration in Joomla 1.5. Everything worked fine except the search. When I search something, the url shows as old one (not like

SEO friendly URL issue

I have a problem in after creating SEO friendly links in my site. here is the .htaccess file codes. RewriteEngine On RewriteRule ^www/category/([0-9]+)/(.*?).html$ www/product/productlist.php?category

cakephp plugin to make URL SEO friendly

How do I make cakephp website URL SEO friendly? Is there a plugin available for cakephp 1.2.6

Convert to SEO friendly URL

I’m trying to make my website URLs SEO-friendly, and I’m having problems… How can I change this URL: http://www.example.com/media.php?album=Album_1&page=1 To this kind of URL: http://www.example

SEO friendly url in rails

I’m building a website for last minutes holidays. Now I’m busy building seo friendly url. Each last minutes has one country and one city. The way I want to let url’s look like is te following: For the

Producing SEO friendly URL in javascript

I have a PHP function that converts a URL to an SEO friendly URL: function seo_url($input){ $input = str_replace(array(‘, -), , $input); //remove single quote and dash $input = mb_convert_case($

SEO Friendly URL Rewriter Parameters

I would appreciate you advice on how to incorporate parameters into SEO Friendly URLs We have decided to have the techie parameters first, followed by the SEO Slug /product/ABC123/fly-your-own-hel

SEO friendly URL in Classic ASP?

I have website developed in classic ASP. The URL is not SEO friendly at present. Please suggest how I can make the SEO friendly URL for my website in ASP. Is there any supporting functions which can h

Answers

First of all you didn’t write what framework do you user. I describe what you want to do on Symfony framework

First solution

http://www.symfony-project.org/jobeet/1_4/Doctrine/en/05#chapter_05_route_customizations

  1. Change routes to routing engine understand the “Nice urls”
  2. Change controller’s action which is responsible for searching the right record with your’s article

You can enhance the solution by declare sluging function and use it directly in routes

Second solution

Use any blogging solution which already supports it – as wrote ceejayoz

You could use PHP and Apache together. Specifically Apache Forcetype. This article explains how to use Forcetype.

Let’s say you have a URL like this: http://www.example.com/article/seo-friendly-example

The .htacess file would look like this:

<Files article>
  ForceType application/x-httpd-php 
</Files>

The PHP would look something like this:

<?php
    list(,$slug) = explode("/", $_SERVER['REQUEST_URI']);
?>

The value of $slug would be seo-friendly-example. This would be a key in your database for that article.

I’m not sure why people are being so deliberately obtuse here…

What you are looking for is mod_rewrite, an apache module for URL rewriting.

In your .htaccess file (you might need to make it) put:

<IfModule mod_rewrite.c>
RewriteEngine on

RewriteRule ^blog//([0-9]+)//.*$ /blog.php?post=$1 [L]
</IfModule>

This means when you go to /blog/10/any-old-bit-of-text/ behind the scenes it is identical to if you visited /blog.php?post=10.

The ([0-9]+) bit is called a regular expression (or regex), and matches any number. The .* means match anything. The ^ anchors to the start of the query and the $ anchors to the end. slashes (/) are escaped as //.