How to redirect all links containing a certain string using htaccess?

In particular, the template links to the right mydomain.com/mypage.php?j=случайная line


examples of good links
mydomain.com/mypage.php?j=sdhfv289gf234f834
mydomain.com/mypage.php?j=ascf2i9bf34f34f
mydomain.com/mypage.php?j=ws0cq0wjd023d34f


All other links should be otherdirected one other page, for example mydomain.com/bad.php
October 8th 19 at 02:41
2 answers
October 8th 19 at 02:43
Surely we can do better, but it seems to work:
RewriteEngine On<br> RewriteCond %{REQUEST_URI} !^/bad\.php<br / > RewriteCond %{REQUEST_URI} !^/mypage\.php [OR]<br> RewriteCond %{QUERY_STRING} !^j=[^&]+$<br> RewriteRule .* /bad.php? [R=301,L]<br>
I do not work, good links also redirects - Eulalia22 commented on October 8th 19 at 02:46
October 8th 19 at 02:45
and it looks like a wrong link an example?
For the correct links should be some rule for example 3 the first letter then 1 number 3 letters and numbers, or define the wrong links, it will be impossible

Find more questions by tags htaccess