When I type url site.com/phone/random-text-string/1 , I get the first phone (id : 1) on the db. When I change the ID to, say, 5, “random-text-string” stays the same, but I want it to be fetched from the db and my htaccess should redirect me to that page automatically.
The desired result is : site.com/phone/selectedphonemodel/phoneid
This time it isn’t a server config problem, but instead it’s a PHP problem. After you get the phone from the database, then you need to compare that phone’s model name (URL-ified) against the string that’s in the URL. If they’re different, then send a header redirect using the correct model name.