I need to add some non-php code to the pages of a website for beeing able to redirect the user to a different website (a mobile version) in case the page was accesed from a mobile device.
If user has javascript enabled, I can put a script that has as src a page from another website that checks with php if the device is mobile and, if it is, redirects the user with document.location.href to the mobile website.
Is there any way I can do this redirect if the user doesn't have javascript?
Thank you!
redirect question
Moderator: General Moderators
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: redirect question
Check $_SERVER['HTTP_USER_AGENT'] and then use header() to redirect.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Re: redirect question
The code from the first website shouldn't contain PHP
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: redirect question
Without javascript or PHP, the only way that I know of would be an .htaccess file if using Apache. You can use the RewriteCond %{HTTP_USER_AGENT} along with a RewriteRule.adeenutza wrote:The code from the first website shouldn't contain PHP
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.