Redirect 如何使用.htcaccess将仅用于移动观众的特定页面重写/重定向到外部URL?

Redirect 如何使用.htcaccess将仅用于移动观众的特定页面重写/重定向到外部URL?,redirect,mobile,joomla,rewrite,Redirect,Mobile,Joomla,Rewrite,我想知道是否有可能在.htcaccess文件中编码,并使其重定向/重写到外部url。这是一个Joomla遗址 我想要的是,使用手机或平板电脑等移动设备的访问者在访问此页面时应重定向: 这是我希望他们指向的url: 我发现了这条线索,并用它作为灵感,尝试了一些代码组合,但我无法将代码正确地组合在一起 此代码来自另一个线程(用于wordpress站点),我不确定保存什么以及将代码放在何处: # BEGIN Mobile redirect for the video <IfModule

我想知道是否有可能在.htcaccess文件中编码,并使其重定向/重写到外部url。这是一个Joomla遗址

我想要的是,使用手机或平板电脑等移动设备的访问者在访问此页面时应重定向:

这是我希望他们指向的url:

我发现了这条线索,并用它作为灵感,尝试了一些代码组合,但我无法将代码正确地组合在一起

此代码来自另一个线程(用于wordpress站点),我不确定保存什么以及将代码放在何处:

# BEGIN Mobile redirect for the video 
<IfModule mod_rewrite.c>
    RewriteEngine On
    # stuff to let through (ignore)
    RewriteRule ^mobile/ - [L]
    # redirect /video.html to /mobile/index.html for mobile browsers
    RewriteCond %{HTTP_USER_AGENT} "android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC]
    RewriteRule ^video\.html$ /mobile/index.html [L,R=302]
</IfModule>
# END Mobile redirect
#开始视频的移动重定向
重新启动发动机
#要泄漏的内容(忽略)
重写规则^mobile/-[L]
#将移动浏览器的/video.html重定向到/mobile/index.html
重写Cond%{HTTP|u USER|u AGENT}“android |黑莓| ipad | iphone | ipod | iemobile | opera mobile | palmos | webos | googlebot mobile”[NC]
重写规则^video\.html$/mobile/index.html[L,R=302]
#结束移动重定向
我正在使用该功能

在mytemplate/index.php的顶部:

include 'pathtolibrary/Mobile_Detect.php';
$detect = new Mobile_Detect();
$mob = JURI::base()."index.php?option=com_yourcomponent&view=mobile";
if ($detect->isMobile()) JFactory::getApplication()->redirect( $mob, $error, 'error' );
因此,您不需要使用htaccess。 你可以在我的网站上看到它

我正在使用该功能

在mytemplate/index.php的顶部:

include 'pathtolibrary/Mobile_Detect.php';
$detect = new Mobile_Detect();
$mob = JURI::base()."index.php?option=com_yourcomponent&view=mobile";
if ($detect->isMobile()) JFactory::getApplication()->redirect( $mob, $error, 'error' );
因此,您不需要使用htaccess。 您可以在我的网站上看到它

$browser=JBrowser::getInstance();
如果($browser->isMobile()==true)
echo“移动网站”

”; 其他的 echo“标准网站”

”; echo“有关用户代理的更多信息:

”;变量转储($browser);
$browser=JBrowser::getInstance();
如果($browser->isMobile()==true)
echo“移动网站”

”; 其他的 echo“标准网站”

”; echo“有关用户代理的更多信息:

”;变量转储($browser);
Joomla已经具备检测手机的能力。为什么要包含并维护另一个额外的类?好吧,听起来很合理,你能给出一个如何使用joomla的代码的线索吗?joomla已经具备了检测手机的能力。为什么要包含并维护另一个额外的类呢?好吧,听起来很合理,您能给出一个关于如何使用joomla的代码来实现它的线索吗?