Al jazary icon and logo Al jazary

best way to create seo friendly url in php and htaccess - Al jazary

published 02 Jul 2016

best way to create seo friendly url in php and htaccess

in previous update we have show you how to using htaccess to setting cache file transfer, and now we will use mod_rewrite engine that convert any url request from browser into php paramater url. for example we have basic url like https://al-jazary.com/index.php?link=create-url-friendly-php-htaccess than we change that into https://al-jazary.com/create-url-friendly-php-htaccess.

first, we need .htaccess file, find it and edit using notepad or any software like that. add this code below:

RewriteEngine On
RewriteRule  ^([A-Za-z0-9-]+)?$  index.php?link=$1  [NC,L]

to be able rewrite, we must turn on it with RewriteEngine On then in 2nd line we hold the value of url after domain.com/url-url-url and made request as php get with spesific url index.php?link=url-url-url than "flags" that rule as [NC,L] so it's mark as Not Case sensitive and stop rewrite any rule after this.

and now with this setting everything url opened in your domain it will request to php file with parameter you set, than in in php we can get it using $_GET["link"] for example. then search that value in database or directory.

this is the best way to create seo friendly url in php and htaccess, we can use dynamic url just like php get.

phpseo updated 02 Jul 2016

0 total comments

Add Comment

Sitemap

    templates

    htaccess

    php

    tools

    articles

    hardware

Top articles