1

This is the URL path I currently use:

/index.php?pid=211 I want to get the URL path as /index/211/title of the product 

How to do user friendly URLs in PHP?

And how to get the value of the "title"?

Regards,

1

1 Answer 1

3

In you html code you must write like this:

<a href='http://www.domain.com/index/211/title-goes-here'>url_text</a> 

and in the htaccess file adapt the following:

Options +SymLinksIfOwnerMatch RewriteEngine on RewriteRule ^([a-zA-Z-]+)$ index.php?action=$1 [NC,L] RewriteRule ^(member)-([0-9-]+)$ index.php?action=member&id=$2 [NC,L] RewriteRule ^([a-zA-Z-]+)/([a-zA-Z-]+)-([0-9-]+)$ index.php?action=$1&saction=$2&sid=$3 [NC,L] RewriteRule ^([a-zA-Z-]+)/([0-9-]+)$ index.php?action=$1&id=$2 [NC,L] RewriteRule ^([0-9-]+)/([a-zA-Z0-9-]+)/([a-zA-Z0-9-]+)/([a-zA-Z0-9-]+)/(.*).html$ index.php?action=details&id=$1&p1=$2&p2=$3&p3=$4 [NC,L] 
Sign up to request clarification or add additional context in comments.

4 Comments

if you dont understand , please re comment
please write your htaccess code here and also the link that you are testing
echo '<a href=domain.co.uk/friendly_url'; echo $info121['id_product']; echo "/"; echo $info121['name']; echo '>'; echo $info121['name'];echo' </a>';
ok, just adapt one of the rules from the htaccess file in order to best suit your link, like this: RewriteRule ^([a-zA-Z0-9_]+)/([0-9]+)/([a-zA-Z0-9]+)$ your_file.php?action=details&id=$2

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.