Create friendly seo link

Discuss coding issues, and scripts related to PHP and MySQL.
mluci12
Posts:39

Create friendly seo link

Hello!
When i create PHP apps i create link like domain.com/page?variable=&variable2 , but this is not seo friendly.
How can i make link like: domain.com/variable/variable2 and GET variable value.

Admin Posts:805
Hi,
You can create friendly seo links with mod_rewrite in the .htaccess file.
For example:

Code: Select all

Options +FollowSymLinks
RewriteEngine On

RewriteRule ^([A-z0-9_\-]+)/([A-z0-9_\-]+)$ page.php?v1=$1&v2=$2 [NC,L]
Then, in html add the friendly link:

Code: Select all

<a href="//domain.com/some_val/other_val" title="Text">Text</a>
And, in php you can use a code like this to get the "some_val" and "other_val":

Code: Select all

$v1 = isset($_GET['v1']) ? $_GET['v1'] :'';
$v2 = isset($_GET['v2']) ? $_GET['v2'] :'';
To learn about this, just look on the net for: " mod_rewrite htaccess ".
- You need to know /learn a little about RegExp (regular expressions) to write the expression to "RewriteRule" according to the link you want.