Here the request code itself all works fine when access to the page is of the type site.com/profile?id=123 or site.com/123 but gives an error when access is of the form of site.com/idn123

Here is the code that pulls the user id

if (isset($_GET['id'])) {$id =$_GET['id']; } else { exit("Error 1 !");} if($id == 0) { exit("<p>Bad URL</p>"); } 

When requesting site.com/idn123, it gives a bad url error. In .htaccess, this is what is entered for changing to idn

 RewriteEngine on RewriteRule ^([a-zA-Z0-9_-]+)$ profile?id=$1 RewriteRule ^([a-zA-Z0-9_-]+)/$ idn?id=$1 RewriteRule ^idn([0-9]+)$ profile?id=$1 

Tell me what's wrong and why does it give an error? What needs to be fixed?

  • The first condition is fulfilled in .htaccess RewriteRule ^ ([a-zA-Z0-9 _-] +) $ profile? Id = $ 1 - Alex Kapustin

1 answer 1

  RewriteRule ^idn([a-z0-9]+)$ profile.php?id=$1 [NC,L] 

So try it if I understand correctly!

  • does not help (It is necessary that the php code could determine the id of the request idn as well as the profile request? id = - OverLoader