I have a this page get_cost.php and when URL gets GET method "id" data it will be like this get_cost.php?id=4. So I want to change this url like this website.com/get_cost/4 what I must do for this in php?
Asked
Active
Viewed 41 times
1
-
[pretty url php](https://www.google.co.uk/search?q=pretty+url+php&oq=pretty+url+php&aqs=chrome..69i57.272j0j7&sourceid=chrome&ie=UTF-8) – Script47 Aug 16 '16 at 20:52
1 Answers
0
This question already answered many times before. First you must search your question in site. You can do it with RewriteRule. You must use .htaccess code for this. To get this add this code to your .htaccess file.
RewriteEngine On
RewriteRule ^get_cost/([0-9]+)/ get_cost.php?id=$1
If your filename different you can change get_cost
from the code.

NurlanXp
- 156
- 2
- 14
-
-
Create a file named .htaccess (with dot) in root folder of your site in a localserver or hosting and add above code. – NurlanXp Aug 16 '16 at 20:55
-
windows did not allowed to put dot to front of the name. What I must do? – Maxmud Abusari Aug 16 '16 at 20:57
-
You can use Notepad++ to rename it or create new file named with .htaccess – NurlanXp Aug 16 '16 at 20:58
-
1