You might think this topic looks a little odd. Why would someone need to hide the website for desktop users? There could be number of reasons for doing so.The site is not designed for larger screensYou ...
It's a nice solution, however bear in mind that this can be very bad for SEO.
Also, I would add a short message to let visitors know they can only access the website on mobiles, so e.g. inserting just before 'die();'
PHP:
echo '<div style="background:#000;color:#FFF;width:100vw;height:100vh;display:flex;align-items:center;justify-content:center;flex-direction:column;">Sorry, this website can be viewed on mobile devices ONLY</div>';