Здравствуйте.
Имеется мобильный сайт на движке GoMobi и основной сайт. Нужно сделать редирект. Если на основной сайт заходят с мобильного устройства, то перенаправляется на мобильный.
Скрипт создания мобильного сайта GoMobi сам сгенерировал код, осталось только правильно его применить, с чем, собственно, у меня и возникли трудности.
Решил попробовать сделать редирект с помощью файла .htaccess.
Вот сам код htaccess, который GoMobi пишет, что его нужно вставить на основной сайт:
Код
# This .htaccess file redirects mobile browsers and devices to an alternate destination
#
################################################################################
#######
# Ensure rewriting is on
RewriteEngine On
SetEnv isTablet=NO
BrowserMatchNoCase iPad isTablet=YES
BrowserMatchNoCase Tablet isTablet=YES
BrowserMatchNoCase .*Android(?!.*Mobile).* isTablet=YES
# Check for redirect param
RewriteCond %{QUERY_STRING} ^.*redirect=true.*
RewriteRule ^(.*)$ - [co=mob_prevent_redirect:false:.www.novinteh.ru:0:/]
RewriteCond %{QUERY_STRING} ^.*redirect=false.*
RewriteRule ^(.*)$ - [co=mob_prevent_redirect:true:.www.novinteh.ru:7200:/]
RewriteCond %{HTTP_COOKIE} !mob_prevent_redirect=true [OR]
RewriteCond %{QUERY_STRING} ^.*redirect=true.*
# Don't redirect if its false
RewriteCond %{QUERY_STRING} !^.*redirect=false.*
# Exclude certain paths e.g. cpanel admin etc.
RewriteCond %{REQUEST_URI} !(.*)cpanel(/?)$
RewriteCond %{REQUEST_URI} !^/wp-(.*)$
RewriteCond %{REQUEST_URI} !/xmlrpc.php
# Exclude certain extensions e.g. images, docs etc
RewriteCond %{REQUEST_URI} !(.*)\.(?i:jpg|jpeg|webp|gif|bmp|png|js|css|txt|pdf|doc|docx|xls|xlsx|rar|zip|7z|mpg|mp
4|mpeg|divx|avi|ogv|webm|mp3|ogg|wav|aac)$
# Switch based on significant accept headers
RewriteCond %{HTTP_ACCEPT} "text/vnd.wap.wml|application/vnd.wap.xhtml\+xml" [NC,OR]
# Specific devices/mandufacturers
RewriteCond %{HTTP_USER_AGENT} "iphone|ipad|ipod|android|nokia|ios|opera m(ob|in)i|iemobile|symbian|samsung|sec-|htc|huawei|ericsson|sonyericsson|blackberry|motorola|sagem|kyocera|zte|kddi|doc
omo|j-phone|kwc|lenovo|lg|mot|softbank|nec|audiovox|alcatel|sharp|sie-|sanyo|sendo|amoi|xda|bird|benq|palm|pantech|panasonic|fly|asus-|baiduispider|googlebot-mobile|nintendo|psp|dalvik|windows ce|foma|brew|webos|fennec|netfront|teleca|obigo|vodafone|up.browser|portalmmm" [NC]
#REDIRECT_TO_LINKED_PAGE#
RewriteRule .? - [S=1]
RewriteRule .? - [S=4]
RewriteCond %{REQUEST_URI} ^(\/?)$
RewriteRule .? - [S=1]
RewriteRule ^(.*)$ http://m.novinteh.ru/w/www.novinteh.ru/$1 [L,R=302]
#END_REDIRECT_TO_LINKED_PAGE#
RewriteRule ^(.*)$ http://m.novinteh.ru [L,R=302]
А вот содержимое файла .htaccess на основном сайте:
Код
DirectoryIndex index.php
AddType text/x-server-parsed-html .html
RewriteEngine on
RewriteRule ^GoodsPrice(.+)-(.+).html$ GoodsPrice.php?item_id=$1&first_num=$2 [NC,L]
RewriteRule ^GoodsPrice(.+).html$ GoodsPrice.php?item_id=$1 [NC,L]
RewriteRule ^GoodsSeries(.+)-(.+).html$ GoodsSeries.php?item_id=$1&first_num=$2 [NC,L]
RewriteRule ^GoodsSeries(.+).html$ GoodsSeries.php?item_id=$1 [NC,L]
RewriteRule ^showNews(.+).html$ ?mod=SiteNews&act=2&news_id=$1 [NC,L]
RewriteRule ^showNews(.+).html$ ?first_num=$1&mod=SiteNews&act=2&news_id=$2 [NC,L]
RewriteRule ^News_subsribe.html$ ?mod=SiteNews&act=4&pg_ok=news_sub [NC,L]
RewriteRule ^NwShowNews(.+).html$ ?mod=SiteNews&act=2&mode=nw&news_id=$1 [NC,L]
RewriteRule ^PrintNews(.+).html$ ?mod=SiteNews&act=7&mode=nw&id=$1 [NC,L]
RewriteRule ^Article_(.+).html$ ?mod=SiteArticles&act=2&article_id=$1&item_id=$2 [NC,L]
RewriteRule ^SiteArticles(.+).html$ ?mod=SiteArticles&act=1&item_id=$1 [NC,L]
RewriteRule ^PrintArticle(.+).html$ ?mod=SiteArticles&act=5&article_id=$1 [NC,L]
RewriteRule ^NwArticle_(.+).html$ ?mod=SiteArticles&act=2&mode=nw&article_id=$1&item_id=$2 [NC,L]
RewriteRule ^FAQ(.+).html$ ?mod=FAQ&act=1&item_id=$1 [NC,L]
RewriteRule ^showFAQ(.+).html$ ?mod=FAQ&act=2&faq_id=$1 [NC,L]
RewriteRule ^NwShowFAQ(.+).html$ ?mod=FAQ&act=2&mode=nw&faq_id=$1 [NC,L]
RewriteRule ^PrintFAQ(.+).html$ ?mod=FAQ&act=5&id=$1 [NC,L]
RewriteRule ^Votes.html$ ?mod=Votes&act=3 [NC,L]
RewriteRule ^Search.html$ ?mod=Search&act=1 [NC,L]
RewriteRule ^Search(.+).html$ ?first_num=$1&keyword=$2&mod=Search&act=1 [NC,L]
RewriteRule ^result_SiteArticles(.+).html$ ?mod=SiteArticles&act=2&article_id=$1&item_id=$2 [NC,L]
RewriteRule ^result_SiteNews(.+).html$ ?mod=SiteNews&act=2&news_id=$1 [NC,L]
RewriteRule ^result_FAQ(.+).html$ ?mod=FAQ&act=2&faq_id=$1&item_id=$2 [NC,L]
RewriteRule ^result_cFAQ(.+).html$ ?mod=FAQ&act=0&item_id=$1 [NC,L]
RewriteRule ^result_cSiteArticles(.+).html$ ?mod=SiteArticles&act=0&item_id=$1 [NC,L]
RewriteRule ^Goods(.+).html$ ?mod=Goods&act=1&item_id=$1 [NC,L]
RewriteRule ^Goods(.+).html$ ?first_num=$1&mod=Goods&act=1&item_id=$2 [NC,L]
RewriteRule ^ViewGood(.+).html$ ?mod=Goods&act=2&good_id=$1 [NC,L]
RewriteRule ^View_nw_Good(.+).html$ ?mod=Goods&act=2&good_id=$1&mode=nw&title=$2 [NC,L]
RewriteRule ^BuyForm.html$ ?mod=Goods&act=4&run=1 [NC,L]
RewriteRule ^CheckOutForm_Good(.+).html$ ?mod=Goods&act=8&run=1&good_id=$1 [NC,L]
RewriteRule ^go_adv_search.html$ ?pgid=go_adv_search.htm [NC,L]
RewriteRule ^gsearch.html$ ?mod=Goods&act=5 [NC,L]
RewriteRule ^scart.html$ ?mod=Goods&act=3 [NC,L]
RewriteRule ^cat_select(.+).html$ ?mod=Goods&act=1&item_id=$1&sort=$2&first_num=$3&goods_set=1 [NC,L]
RewriteRule ^pg_select(.+).html$ ?mod=Goods&act=1&item_id=$1&sort=$2&first_num=$3&goods_set=2 [NC,L]
RewriteRule ^select_all(.+).html$ ?mod=Goods&act=1&item_id=$1&sort=$2&first_num=$3&goods_set=3 [NC,L]
RewriteRule ^print_good_(.+).html$ ?mod=Goods&act=6&item_id=$1&sort=$2&goods_set=$3&first_num=$4&meth=1 [NC,L]
RewriteRule ^price_send.html$ ?mod=Goods&pgid=price_send.htm&act=7 [NC,L]
RewriteRule ^order_history.html$ ?mod=Goods&act=11 [NC,L]
RewriteRule ^ListOrder_(.+).html$ ?mod=Goods&act=12&zakaz_id=$1 [NC,L]
RewriteRule ^PayOrder_(.+).html$ ?pgid=g_order.htm&zakaz_id=$1 [NC,L]
RewriteRule ^Page(.+).html$ ?pgid=$1 [NC,L]
RewriteRule ^Page(.+).html$ ?mod=Menu&act=1&item_id=$1 [NC,L]
RewriteRule ^Page(.+).html$ Page$1.html?pgid=$2 [NC,L]
RewriteRule ^Auth.html$ ?mod=Auth [NC,L]
RewriteRule ^ReqAuth.html$ ?mod=Auth&act=3&pgerr=auth_notRegistreted [NC,L]
RewriteRule ^contact.html$ ?mod=Auth&act=2 [NC,L]
RewriteRule ^PhotoPages(.+).html$ ?mod=PhotoPages&act=1&item_id=$1 [NC,L]
RewriteRule ^PhotoPage(.+)_(.+).html$ ?mod=PhotoPages&act=2&photo_id=$1&item_id=$2 [NC,L]
RewriteRule ^DownLoad(.+).html$ ?mod=DownLoad&act=1&item_id=$1 [NC,L]
RewriteRule ^File(.+).html$ ?mod=DownLoad&act=2&file_id=$1 [NC,L]
RewriteRule ^contacts/$ Page400.html [NC,L]
Сам в этом не шарю, как объединить эти коды, пробовал вставлять в начале, редактировать, не получалось ничего - сайт попросту не загружался совсем.
В связи с этим, прошу помощи у знающих, разбирающихся в этом, людей.
Если что-то в этом шарит и может выполнить задачу - за работу выдам поощрение в размере 300 рублей.