Answer the question
In order to leave comments, you need to log in
Beautiful URL problem (htaccess), how to fix?
Hello, I tried to make a CNC (beautiful url) for a self-written site and there was one problem that I can’t solve. I've searched half the internet and nothing came up.
I implement CNC through htaccess, now all its code looks like this:
RewriteEngine on
RewriteRule ^module_news/([0-9]+)$ module_news/fullnews_page.php?id=$1 [QSA,NC]
Answer the question
In order to leave comments, you need to log in
It’s more correct to set up the modrewright so that it sends any request to index.php, and already parse the string in it as you like. More about the front controller . An example in php .
Parsing the url string and matching the address with the desired module (controller / action) in the front controller is called routing.
Redirects:
You can search for more details, for example, on the request " htaccess redirect ".
1. The engines of these urls can have up to 5, all that can be done is 301
2.
RewriteCond %{QUERY_STRING} (^|&)id\=([0-9]{1,})\$($|&)
RewriteRule ^.+[^/]/fullnews_page\.php$ /$1/%2? [L,R=301]
[0-9]{1,}
- from zero to 9, one or more times (this is the second bracket) .+[^/]
more than 1 character but not a slash, before the slash (well, a crutch, you can also use quantifiers) /$1/%2
the first bracket from the wheel and the second from the conda ?
- at the end, remove the get parameter, leave a beautiful cnc
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question