使用 JavaScript 将子域名替换为其他子域? [英] Replace subdomain name with other subdomain Using JavaScript?

查看:40
本文介绍了使用 JavaScript 将子域名替换为其他子域?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将子域名从news.domain.com/path/.."替换为mobile.domain.com/path/"..", 使用 JavaScript

I'm trying to replace the subdomain name from "news.domain.com/path/.." to "mobile.domain.com/path/..", using JavaScript

知道如何实现这一目标吗?

Any idea how to achieve this?

推荐答案

我尝试使用 java 脚本但没有成功,对于我的情况,我在 .httaccess 文件中使用以下代码

I tried using java script but no luck and for my case i use the below code in .httaccess file

RewriteCond %{HTTP_USER_AGENT} "iphone|ipod|android" [NC]
RewriteCond %{HTTP_HOST} !^mobile.domain.com
RewriteRule ^(.*)$ http://mobile.domain.com/ [L,R=302]

它将把新闻"子域替换为移动"子域.希望对大家有所帮助.

it will replace "news" sub domain to "mobile" sub domain. hope it will help any one.

这篇关于使用 JavaScript 将子域名替换为其他子域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆