Dynamic rewriting of htaccess urls

I have a problem with dynamic URL rewriting.

I have two different types of URLs that I need to rewrite for SEO purposes. Since they are not fixed, but dynamic - I cannot just set the rules in htaccess, as usual. In addition, I also have a couple of fixed URLs.

All slug names are unique and are stored in two different tables in my database.

(They must point to view_category.php, and both levels of menu names must be sent together)

What is the best way to manage dynamic URLs while relying on htaccess? Perhaps someone knows the class to use?

PS: My problem is not in writing the rules, but in how to extract the rules from my database in htaccess.

I am afraid that I am making it more complicated than it really is. All help is appreciated!

Thanks in advance,

Hello

+4
source share
1 answer

You have essentially two options:

  • Grab all incoming requests (except for images, style sheets, etc.) into the server controller (PHP, ASP or any server language that you use) and redirect there using header(....) . This is the easiest and most popular way.

  • Use the Apache RewriteMap directive to often write your cards to text files that mod_rewrite can look for.

The RewriteMap alternative may be useful in specific optimization scenarios with a lot of traffic. Usually the chances are that you are satisfied with the first option.

+2
source

Source: https://habr.com/ru/post/1333991/


All Articles