P
P
picka2020-05-12 07:50:06
PHP
picka, 2020-05-12 07:50:06

Replacing URL from GET to CNC?

Instead of test.com/post.php?Project_Id=1, convert the url to CNC - test.com/post/habr with automatic embedding of the post title in the url.
As you can see from the example, posts are retrieved from the database via a GET request and I want to make the url look like a CNC.

I know that the issue has been resolved for a long time and there are many examples, but all I find is a change in the .htaccess file. Can someone suggest or give a link to the article.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya, 2020-05-12
@picka

Use ready-made routers (you can peep in slim microframeworks: www.slimframework.com ).
htaccess should be used to reduce all requests to 1 script, in which the router will already connect the desired file (if we talk about Apache)
In the database, you need to store the URL of the post by which it will be available, and then in the handler / controller (to which the router will transfer according to the specified rule ) search for a record not by id (as in the first version), but by url (as in the CNC version)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question