This question has already been answered:
I need to make the link page1 from the link page.php? Id = 1 link to remove .php? Id = and can it be done with the help of .htaccess
This question has already been answered:
I need to make the link page1 from the link page.php? Id = 1 link to remove .php? Id = and can it be done with the help of .htaccess
A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .
You need to do something like this here.
RewriteRule ^page([0-9]*)(/?)$ /page.php?id=$1 [L,QSA]
That is, we convert the path /page123
to /page.php?id=123
using regular expressions in the .htaccess file
As for the link to this question , then everything is done simply - all query paths are passed as an _route
variable in a GET request to the index.php file. This allows all the routing logic to be implemented in php - to parse the query string and include the necessary files via require
or include
. This approach is more rational in the sense that it is better to make a single routing system, rather than insert crutches every time, like what I suggested now.
page123
then the effect will be as if you follow the link page.php?id=123
. The reference page123
means nothing by default, since it does not indicate a file (or a folder). In htaccess, we decipher this link and therefore it starts to work - RussCoderRegister in .htaccess
RewriteEngine On RewriteRule ^page([a-zA-Z0-9_-]+)$ page.php?id=$1 RewriteRule ^page([a-zA-Z0-9_-]+)/$ page.php?id=$1
Source: https://ru.stackoverflow.com/questions/550184/
All Articles