Embark on a journey of knowledge! Take the quiz and earn valuable credits.
Take A QuizChallenge yourself and boost your learning! Start the quiz now to earn credits.
Take A QuizUnlock your potential! Begin the quiz, answer questions, and accumulate credits along the way.
Take A QuizPlease log in to access this content. You will be redirected to the login page shortly.
LoginGeneral Tech Bugs & Fixes 3 years ago
User submissions are the sole responsibility of contributors, with TuteeHUB disclaiming liability for accuracy, copyrights, or consequences of use; content is for informational purposes only and not professional advice.
No matter what stage you're at in your education or career, TuteeHUB will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.
Please log in to access this content. You will be redirected to the login page shortly.
Login
Ready to take your education and career to the next level? Register today and join our growing community of learners and professionals.
Your experience on this site will be improved by allowing cookies. Read Cookie Policy
Your experience on this site will be improved by allowing cookies. Read Cookie Policy
manpreet
Best Answer
3 years ago
I need help for an automatic redirect. I need an auto redirect to https with www, mobile device without www and language detect:
1.https with www 2.on mobile devices to https://m.example.com/ 3.auto detect language to https://www.example.com/en/ or /el/ or /ru/ Mobile device https://m.example.com/en/ or /el/ or /ru/
This my .htaccess file
Options -Indexes
AddDefaultCharset utf-8
ErrorDocument 402 /404.php
ErrorDocument 403 /404.php
ErrorDocument 404 /404.php
ErrorDocument 500 /404.php
ErrorDocument 501 /404.php
ErrorDocument 502 /404.php
DirectoryIndex index.php
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]
#RewriteCond %{HTTP:Accept-Language} ^en [NC]
#RewriteRule ^$ /[L,R=301]
#RewriteCond %{HTTP:Accept-Language} ^el [NC]
#RewriteRule ^$ /el/ [L,R=301]
#RewriteCond %{HTTP:Accept-Language} ^ru [NC]
#RewriteRule ^$ /ru/ [L,R=301]
RewriteBase /
RewriteRule ^/$ index.php [L,QSA]
RewriteRule ^ru/(.*)$ /$1?lang=ru [L,QSA]
RewriteRule ^en/(.*)$ /$1?lang=en [L,QSA]
RewriteRule ^el/(.*)$ /$1?lang=el [L,QSA]
RewriteRule ^ajax/(.*)$ /$1?mode=ajax [L,QSA]
RewriteRule ^robots.txt$ misc.php?controller=robots [L,QSA]
RewriteRule ^image/([0-9]+)x([0-9]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+).jpg$ resize.php?apid=$3&key=$4&w=$1&h=$2 [L,QSA]
RewriteRule ^attachment/([a-zA-Z0-9]+)/([0-9]+)/(.*)$ attachment.php?dmuid=$1&order=$2&original=$3 [L,QSA]
RewriteRule ^item/print/([a-zA-Z0-9_-]+)_([0-9]+)$ item.php?mode=print&controller=item&id=$2 [L,QSA]
RewriteRule ^item/([a-zA-Z0-9_-]+)_([0-9]+)$ item.php?controller=item&id=$2 [L,QSA]
RewriteRule ^moderation/list/(waiting|inactive|moderated)/$ moderation_list.php?controller=$1 [L,QSA]
RewriteRule ^my/(waiting|inactive|moderated)/$ my.php?controller=$1 [L,QSA]
RewriteRule ^my/message/([0-9]+)$ my_messages.php?controller=message&mid=$1 [L,QSA]
RewriteRule ^my/messages/([0-9]+)$ my_messages.php?controller=messages&aid=$1 [L,QSA]
RewriteRule ^my/messages/(sent|archive)/$ my_messages.php?controller=$1 [L,QSA]
RewriteRule ^pay/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/$ gateway.php?controller=gateway&code=$1&action=$2 [L,QSA]
RewriteRule ^pay/([a-zA-Z0-9_-]+)/$ pay.php?controller=$1 [L,QSA]
RewriteRule ^s-login/([a-zA-Z0-9_-]+)/$ /s-login.php?provider=$1 [L,QSA]
RewriteRule ^list/$ list.php?controller=list&query=list [L,QSA]
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/$ list.php?controller=list&query=$1/$2/$3/$4 [L,QSA]
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/$ list.php?controller=list&query=$1/$2/$3 [L,QSA]
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/$ list.php?controller=list&query=$1/$2 [L,QSA]
RewriteRule ^([a-zA-Z0-9_-]+)/$ list.php?controller=list&query=$1 [L,QSA]
and those are my php fuctions :
$config['siteurl'] = !empty($_SERVER['HTTP_HOST'])?$_SERVER['HTTP_HOST']:'';
$config['mobileurl'] = 'example.com';
$config['langs'] = array('en', 'el', 'ru',);
$config['lang_names'] = array('en' => 'EN', 'el' => 'EL', 'ru' => 'RU');
if(isset($_GET['lang']) && !empty($_GET['lang'])) {
if (!in_array(trim($_GET['lang']), $config['langs'])) {
$config['lang'] = reset($config['langs']);
} else {
$config['lang'] = trim($_GET['lang']);
}
}
else {
$config['lang'] = $config['langs'][0];
}
unset($_GET['lang']);
if ($config['lang'] != reset($config['langs'])) {
$langPrefix = '/' . $config['lang'];
} else {
$langPrefix = '';
}
include "includes/mobiledetect/Mobile_Detect.php";
if (isset($_GET['force_mobile']) && trim($_GET['force_mobile']) == '0' && !empty($_GET['force_mobile'])) {
setcookie('force_mobile', '0', $time + 60 * 60 * 24 * 365, '/', '.' . $config['siteurl']);
header('Location: https://' . $config['siteurl'] . trim($_GET['ref']));
exit;
}
$mdetect = new Mobile_Detect;
if ($mdetect->isMobile() && !$mdetect->isTablet()) {
if (!$m) {
if (!isset($_COOKIE['force_mobile']) || trim($_COOKIE['force_mobile']) == '1') {
setcookie('force_mobile', '1', $time + 60 * 60 * 24 * 365, '/', '.' . $config['siteurl']);
//header('Location: https://m.' . $config['siteurl'] . $langPrefix . $_SERVER['REQUEST_URI']);
header('Location: https://m.' . $config['mobileurl'] . $langPrefix . $_SERVER['REQUEST_URI']);