How through .htaccess to make so that when entering on:
site.com/siteworked handlersite.phpsite.com/testhandlertest.phpworkedsite.com/category/{dynamic-category-name}did thecategory.phphandler work?
Can you show the simplest example?
For the first rule, the simplest mapping is the expression site/? where /? indicates an optional slash at the end of the line. To write the mapping of this pattern to the handler you need, you should use the RewriteRule directive.
The syntax of the directive, according to the documentation, is as follows ^
RewriteRule Pattern Substitution [flags] where pattern is your url matching pattern, substitution is a replacement, i.e. where this request is forwarded. Next are the flags.
Most often, the flags L (stop viewing rules) and QSA (add original query parameters) are probably used.
it follows that the simplest example for your first URL will be
RewriteRule ^site/?$ site.php [L, QSA] Obviously, for test , the rule will be the same. You can also write a general rule for these two expressions using groups and back links .
RewriteRule ^(site|test)/?$ $1.php [L,QSA] Here in parentheses is the capture group, inside it | denotes или , and $1 in replacement means a link to this group (to the first group). Groups may be several.
To implement the last link, you will also need groups, but now the group name will fall into the group.
RewriteRule ^category/(.*) category.php?cat=$1 [L,QSA] here denotes any character, and * - zero or more repetitions.
Source: https://ru.stackoverflow.com/questions/819485/
All Articles
MVCand you will get an answer to your question. - Evgeny Ivanov