This question has already been answered:

Tell me how to organize the CNC correctly There is an admin panel where the user can create categories of goods + categories 1 + category, etc., etc.

For example, the line would be: my-site.ru/index.php?review=shop&cat=appliance&v-cat=kitchen&b-cat=redmond-rmc-pm330

I bring to the browser:

my-site.ru/shop/appliance/kitchen/redmond-rmc-pm330/

In the .htaccess file:

RewriteRule ^([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/$ index.php?review=$1&cat=$2&v-cat=$3&b-cat=$4[QSA,L] RewriteRule ^([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/$ index.php?review=$1&cat=$2&v-cat=$3 RewriteRule ^([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/$ index.php?review=$1&cat=$2 RewriteRule ^([A-Za-z0-9-]+)/$ index.php?review=$1 

How to write exactly in .htaccess? since so under the categories there can be no more 2 or 3, for example 10, isn’t it possible the next line and so on by analogy?

 RewriteRule ^([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/$ index.php?review=$1&cat=$2&v-cat=$3&b-cat=$4&n-cat=$5[QSA,L] 

Maybe there is a simple solution, is this really what everyone is doing?

Reported as a duplicate by Visman , aleksandr barakin , VenZell , Grundy , Community Spirit Jul 18 '16 at 21:35 .

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 .

    1 answer 1

    Usually such parameters are not processed at the mod_rewrite level, but send all requests to one entry point.

     RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^index.php [L] 

    They write the routing, which extracts the contents of the requested line from the $_SERVER['QUERY_STRING'] , calculates the level of the directory attachment and renders the required page depending on it.

    • Thank you, I understood everything! - ketovpavel