I want to write like this in htaccess

RewriteEngine On RewriteRule red f2.php?fa=5 RewriteRule blue f2.php?fa=6 RewriteRule white f2.php?fa=2 ... 

etc. about 500 pieces. Tell me, how will this affect the site itself? The speed will not slow down or not? Generally what it threatens? Thank!

  • one
    Read here about the last - karmadro4 flag
  • one
    Apache reads .htaccess once, compiles regular expressions and keeps them in memory. Your idea is certainly not optimal, but not critically slow. - karmadro4
  • @ karmadro4, When (not) to use .htaccess files > The first of these is performance. If you’re looking for the .htaccess files. Thus, permitting .htaccess files, whether or not you really want to use them! Also, the .htaccess file is loaded every time a document is requested - Ilya Pirogov
  • one
    @ qwerty17, I just corrected @ karmadro4 at the expense of a single download .htaccess. As regards the performance of 500 regulars, there is nothing special to add to each request : 1. Yes, from an architectural point of view, this is by no means impossible. The @Construct option is much more correct. 2. I do not know how critical this is for your project. For a home page with 10 unique per day or any online store, it may not be critical. For highload this is absolutely unacceptable. - Ilya Pirogov
  • @ qwerty17, you will not correct the sir))) These "beautiful" links that are displayed in the address bar are generated by you. I have already given you a full-scale example, but you don’t understand the principle by itself. - Deonis

1 answer 1

Write

 RewriteRule ^(.*)$ f2.php?fa=$1 [QSA,L] 

and there will be happiness.

  • if I enter site / red then site / f2.php? fa = 5 will be displayed ??? something does not work ... and why also 2 times f2.php.php? - qwerty17
  • No, he will go to site/f2.php?fa=red , maybe rebuild the reception of parameters for it? After all, you see, one line is more convenient than five hundred. php.php fixed - Oleg Arkhipov