Hello. There is a directory in which there are Main sections and subsections.

Links to the main sections are:

website / section / games

website / section / images

website / section / doc

Rule in .htaccess for them:

RewriteRule ^section\/(.+)$ modules/section.php?url=$1 

Question: How to make links to nested sections of the form:

сайт/games/1

where 1 is the subdivision id.

The games link is created automatically when you create a section, so for each section, writing a rule in .htaccess is not an option. We need some kind of universal solution.

I would be grateful for useful information.

  • 2
    Do not do "CNC for subsections." It is necessary to make the CNC for the entire site, and the rest of the routing to do on PHP. - Ipatiev
  • one
    General principle ru.stackoverflow.com/questions/542869 - Visman

1 answer 1

Try this (after the rule for section):

RewriteRule ^(.+)\/([0-9]+)$ modules/index.php?category=$1&id=$2

  • Please try to write more detailed answers. I am sure the author of the question would be grateful for your expert commentary on the code above. - Nicolas Chabanovsky