If user want to access my website from LINUX platform, then website should not access. Can anyone help me to do this?
-
Stack Overflow is a site for programming and development questions. This question appears to be off-topic because it is not about programming or development. See [What topics can I ask about here](http://stackoverflow.com/help/on-topic) in the Help Center. Perhaps [Web Applications Stack Exchange](http://webapps.stackexchange.com/), [Webmaster Stack Exchange](http://webmasters.stackexchange.com/) or [Unix & Linux Stack Exchange](http://unix.stackexchange.com/) would be a better place to ask. – jww May 28 '18 at 10:37
1 Answers
You will have to check the client's User-Agent
header. Be aware that headers can be easily spoofed, so you will never be 100% sure what platform your users come from - if they want to mask this for privacy, to avoid your block or any other reasons.
Similar questions have been asked before: Operating System from User-Agent HTTP Header
Here's a list of User-Agents for Linux specifically: https://developers.whatismybrowser.com/useragents/explore/operating_system_name/linux/
Depending on your server setup, you could check this header and act accordingly either from your website application (e.g. PHP) or in Nginx or Apache .htaccess configuration files.
You might just check the User-Agent
header for the presence of Linux
(case-insensitive). In a regex that would be /linux/i
.

- 1,068
- 2
- 11
- 26
-
1You should probably mention https://stackoverflow.com/a/228281/1030675 – choroba May 28 '18 at 09:42
-
Zoon ,thanks for your reply. My website is on shopify, can you please tell me the command exactly, so I can put that on my .htaccess file? – Danish Anees May 28 '18 at 09:52