Giter Site home page Giter Site logo

asifkibria / os-detect-and-redirect Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 2 KB

A user-centric redirection tool that intuitively guides visitors to platform-specific content or applications based on their OS, leveraging both PHP and JavaScript detection methods.

License: MIT License

PHP 56.95% HTML 43.05%
redirection redirects browser-detection device-detector os-detection

os-detect-and-redirect's Introduction

OS detect and Redirect

"OS detect and Redirect" is a simple script that detects the user's operating system (Desktop, Android, or iOS) and redirects them to a specific URL based on their OS. This can be especially useful for websites that want to guide users to platform-specific content or applications.

Features

  • Server-side detection using PHP.
  • Client-side detection using JavaScript.
  • Supports redirection for:
    • Desktop (all platforms)
    • Android (both mobile and tablet)
    • iOS (both iPhone and iPad)

Installation

  1. Clone this repository:

    git clone https://github.com/AsifKibria/OS-detect-and-Redirect
  2. Navigate to the project directory:

    cd OS-detect-and-Redirect
  3. Upload the PHP or HTML file (depending on which method you're using) to your server.

Usage

PHP Detection

  1. Edit the redirect.php file.
  2. Replace the placeholder URLs (https://ios.example.com, https://android.example.com, and https://desktop.example.com) with your desired redirection URLs.
  3. Include or require the redirect.php at the beginning of your PHP script or use it as your landing page.

JavaScript Detection

  1. Edit the redirect.html file.
  2. Replace the placeholder URLs (https://ios.example.com, https://android.example.com, and https://desktop.example.com) with your desired redirection URLs.
  3. Use the redirect.html as your landing page or embed the JavaScript section in your existing HTML file.

How It Works

  • The PHP method uses the $_SERVER['HTTP_USER_AGENT'] variable to detect the user agent string and determine the user's OS.
  • The JavaScript method uses the window.navigator.userAgent property to achieve the same goal on the client side.

Limitations

  • The JavaScript method is client-side and will redirect the user after the initial page has started loading, which might not be as seamless as the PHP method.
  • User agent strings can be spoofed, so this method is not 100% foolproof. However, for most general use cases, it should work effectively.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

MIT

os-detect-and-redirect's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.