There is an expression

RewriteRule /?([A-Za-z0-9_-]+)/?$ index.php?id=$1 [QSA,L] 

It accordingly changes the query in the form localhost/solutions to localhost/index.php?id=solutions

I need a link like localhost/solutions.php?e=20132009 change to localhost/index.php?id=solutions&post=20132009

Those. As far as I understand, we must also use the $2 variable through the second regular schedule. How to describe it?
The initial one, as I understand it, needs to be changed to /([A-Za-z0-9_-]+.php)/ , so that only files with the extension .php included, but how to stuff it into a variable? Thank you in advance!

  • /?(solution.php?e=)/?$ or change it for this. so that the user is going there, just click index.php?id=solutions&post= question is how to pull the values ​​after e into variable 1? - rusbaron
  • /(solutions.php[?][e][=][0-9]+)/ precisely this, the past does not work - rusbaron
  • /?(events.php???[[e Lil== =) (([0-9+ )/?$ This regular doesn’t work, although on the regularizer check site it fits, but the Apache doesn’t eat it - rusbaron
  • I found another approach on the forum, for some reason it does not work either ((RewriteRule ^ events \ .php \? e = ([0-9] +) index.php? id = events [L, NC, R = 301] - rusbaron
  • RewriteRule ^ events \ .php \? E = ([0-9] +) index.php? Id = events [L, NC, R = 301] - rusbaron

1 answer 1

Correct answer:

 RewriteCond %{QUERY_STRING} e=(.*) RewriteRule ^events\.php?$ index.php?id=events&post=%1 [L,NC,R=301] 

First, a condition is written in which it is possible to isolate the value of the parameter that is passed to the link, then we push it into a variable, and at the end we simply substitute it. How to use a few variables, I unfortunately did not understand how to find write.