Answer the question
In order to leave comments, you need to log in
How to work with URI requests in PHP? How to properly configure routing?
I just started learning back-end, started with PHP, so don't kick me.
Suppose there is a page on the site https://site.ru/spb/post?id=23
So I read various articles about routing in php, and did not understand how they usually go to pages such as spb, Let's say this is the section that is intended for a certain city and there are some posts with id. How the transition to the SPB page is carried out if there are a lot of such cities, you don’t need a code, but explain to me by what methods this can be done.
The first option, as I understand it, is a GET request in the form, it will look like https://site.ru/?city=spb/post?id=23, you can remove extra characters in it. thus there will be a line like https://site.ru/spb/post?id=23.
The second option, I suspect it is possible to implement the POST method, when submit submit will send to the page that exists physically - spb.php then post.php where there will also be links to posts and again work with GET requests to display the pages.
Are there any other options for going to pages that do not physically exist without using GET requests. I ask you not to write crooked options that are not used by web studios.
Answer the question
In order to leave comments, you need to log in
it will look like https://site.ru/?city=spb/post?id=23
on submit, submit will send to the page that exists physically - spb.php then post.phpOf course you can do it, but why? Do you really want to create physically existing pages for each city? I have more than 10 thousand of them in the current project, for example. I'd be tempted to create.
As a rule, frameworks and CMS already have ready-made mechanisms. For a general understanding, I recommend looking at this article
maxsite.org/page/routing
(you don’t have to delve into everything, just understand the mod_rewrite module and what to do with it)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question