0

I am trying to find a way to make pages accessible by pure URL using the $_GET[''].

But instead of the following request URL :

http://mywebsite.com/product.php?=1

I want :

http://mywebsite.com/product/1

Thank you and have a nice day.

Vladimir
  • 5
  • 4

5 Answers5

0

You will need an PHP - URL-Router and mod_rewrite enabled on your Webserver.

If you're not that experienced you can use a PHP Framework, many Frameworks do have a Good Routing integrated.

Have a Look at some example tutroium: http://blogs.shephertz.com/2014/05/21/how-to-implement-url-routing-in-php/

Alexis Peters
  • 1,583
  • 1
  • 10
  • 17
0

You Should using Friendly url in php for creating spec url

you can use this approach:

how-to-create-dynamic-friendly-urls-using-php

how-to-create-friendly-url-in-php

please search friendly url in php

Community
  • 1
  • 1
Hasan Fathi
  • 5,610
  • 4
  • 42
  • 60
  • sorry about the loss of feedback, I started working on my project and forgot about stackoverflow since I found the solution. Y, I found a solution based as well on your answer. – Vladimir Sep 06 '15 at 18:46
0

This can be achieved via url rewriting. Sounds like you want to achieve something like what a lot of PHP frameworks do.

 for example http://codeigniter.com/user_guide/general/urls.html
MichaelS
  • 5,941
  • 6
  • 31
  • 46
Mohan S Gopal
  • 233
  • 3
  • 12
0

Create a htaccess file at root and write this code in that

RewriteEngine On
RewriteRule ^/product.php?id=([0-9]+)$ /product/$1

For more detail read about htaccess

If you are checking it at localhost than make sure you have restart your server after writing this code

Sunil Pachlangia
  • 2,033
  • 2
  • 15
  • 25
0

RewriteEngine On RewriteRule ^([^/]+)/([^/]+)$ index.php?$1=$2

The more number of arguments you enter here that you can access through url

  • $1=$2
  • $1=$2&$3=$4
  • $1=$2&$3=$4&$4=$5

Your answer is given here.

Community
  • 1
  • 1
Ankur
  • 496
  • 1
  • 6
  • 11