I wanted to do so. From this:

http://localhost/site/f2.php?fa=5 

receive

 http://localhost/site/red (т.е. red имеет fa=5 ) 

In the usual way through regular expressions I don’t come out and I did it in a perverse way:

 RewriteEngine On RewriteRule red f2.php?fa=5 RewriteRule blue f2.php?fa=6 RewriteRule white f2.php?fa=2 (и т.д. у меня может получиться сотни таких строк) .......... 

I understand that this is a madhouse and nobody does it ... but if it works and if the speed of the site is not affected then why not .. I wanted to find out if I have about 500 such lines in htaccess, it will affect the speed of the site or something else?

I just really need a person to type a short address in the address bar and find what he needs ... and I also understand that if he clicks in the usual way, it will still be in addr. the line will be written http://localhost/site/f2.php?fa=5 ... well, let it, but it can enter a shorter and get there ... what do you think about this? thank! введите код здесь

  • if you decide to leave it as it is (and you probably will do it at first), be sure to add the [L] flag in each line of RewriteRule red f2.php? fa = 5 [L] Then the program will stop searching after the match. Now you have all the lines get over. - Zhenya Vedenin

1 answer 1

I do this, and my main entry is index.php

 RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-l RewriteRule ^(.*)$ index.php?route=$1 [L,QSA] 

The url can be broken through explode, in your case http: // localhost / site / red, I guess that you need to pull out some data from the database according to the condition where the table column is red, then you can get such a code by typing, the url will remain beautiful, and do not need 100,500 entries in .htaccess, that's about how it looks

 <?php if(isset($_GET['route'])) { $exp = explode($_GET['route'], '/') if($exp[0] == 'site') { $sql = mysql_query("select * from `table` where `name` = '". $exp[1] ."'") or die(mysql_error()); while($row = mysql_fetch_assoc($sql)) { echo $row['id'].$row['value']; } } } ?> ?> 
  • @johniek_comp, thank you ... but something I do not understand) I write like this: RewriteEngine On RewriteCond% {REQUEST_FILENAME}! -f RewriteCond% {REQUEST_FILENAME}! -d RewriteCond% {REQUEST_FILENAME}! -l RewriteRule ^. f2.php? fa = $ 1 [L, QSA] code does not work ... you can clarify what these variables are: name, id and value (route I understand this fa, table is the table where all my data comes from). thank! - qwerty17