1

I have seen various sites now defining the products name in the URL ... for example

http://www.webesite.co.uk/hp/hp-c9701a-cyan-toner-cartridge-original

instead of

http://www.webesite.co.uk/product.php?product=hp-c9701a-cyan-toner-cartridge-original

I am aware and have used a lot the $_GET function to get parameters specified in the URL after the .php file tag, but my question is how do you provide a parameter to replace the file name rather than specifying it at the end of the file name?

I'm working in PHP but I'm not sure if this is achieved using the .htaccess file

I am also interested to know which will perform best SEO wise???

Adam92
  • 436
  • 8
  • 23
  • 1
    [This post](http://stackoverflow.com/a/9649681/558021) might be of some assistance... – Lix May 09 '13 at 18:02
  • that is done with the `.htaccess mode_rewrite`. The Apache Official documentation about this topic can be found [here](http://httpd.apache.org/docs/current/mod/mod_rewrite.html) – MISJHA May 09 '13 at 18:04
  • [Here](http://stackoverflow.com/questions/9105940/user-friendly-urls-mod-rewrite-and-php-redirections/16401451#16401451) is my solution in similar post – Danijel May 09 '13 at 18:17

2 Answers2

2

Yes you need to use the mod_rewrite with .htaccess to redirect to the correct resource.

Here is some usefull link that explaim better what you actually need to do in .htaccess:

http://zenverse.net/seo-friendly-urls-with-htaccess/

And here is a similar thread in Stackoverflow:

How to create friendly URL in php?

Community
  • 1
  • 1
gvsrepins
  • 1,687
  • 2
  • 17
  • 20
0

It's usually done by redirecting every request to index.php using .htaccess and than by parsing (explode()) URL you can get every part of it and treat as a parameter.

You can also read about routing and router classes which are designed to do this work for you.

Jakub Matczak
  • 15,341
  • 5
  • 46
  • 64