是否可以使用javascript重定向URL的主机名?
如果URL包含“内容/文章”,则应保留在相同的URL中。否则,它将所有其他URL从www重定向到www1。
我想我得到了“ / content / articles”部分,但window.location.replace似乎不起作用。
例如:
<script type="text/javascript">
window.onload = function() {
if (window.location.href.indexOf("/content/articles") > -1) {
// Do not redirect
} else {
// Redirect from www to www1
window.location.replace(window.location.protocol + "//" + window.location.hostname.replace("www", "www1")+window.location.pathname);
}
}
</script>Run Code Online (Sandbox Code Playgroud)
我们在.NET中有一个ASP.NET网站,它在生产中成功运行.我们经常在特定的停机时间内维护服务器.因此,我们需要一项功能,可以在停机时将所有请求重定向到维护网页下的网站.我已经使用Custom Handler完成了这项任务,但我的客户对该解决方案并不满意.请建议一些替代解决方案.
我的自定义处理程序代码如下
在web.config下添加
<system.webServer>
<modules>
<add name="CustomModule" type="CustomModule"/>
</modules>
</system.webserver>
Run Code Online (Sandbox Code Playgroud)
在Http Handler下添加
public class CustomModule : IHttpModule
{
// In the Init function, register for HttpApplication
// events by adding your handlers.
public void Init(HttpApplication application)
{
application.EndRequest +=
(new EventHandler(this.Application_EndRequest));
}
}
Run Code Online (Sandbox Code Playgroud)
重定向代码在这里
private void Application_EndRequest(Object source, EventArgs e)
{
if (fileExtension.Equals(".aspx") == true && filePath.Contains("Contact.aspx") == false)
{
context.Response.Redirect("Contact.aspx");
}
}
Run Code Online (Sandbox Code Playgroud) 我知道这是相当简单的重定向添加到Django同HttpResponseRedirect,但有可能使延迟重定向?
我要添加的内容就像是用户的确认页面,基本上会说" 您的请求已成功 "3秒钟,然后被带回登录页面或其他内容.
我已经读到了JQuery,但据我所知,这是为了JavaScript我想尽可能保持这个Python.
有任何想法吗?
像这样的旧网站:www.example.com/oldnews.html
oldnews.html页面改为现在的newnews.html
像这样的新网站:www.example.com/newnews.html
当键入任何一个www.example.com/oldnews.html时,页面会自动重定向到新页面=>
www.example.com/newnews.html
如何将旧页面重定向到新页面?
使用.htaccess文件?
如何在jQuery/JavaScript中创建重定向页面?
我的意思是如何在客户端脚本中的一个程序将浏览器从page1重定向到第n页?
我想将用户从我的 http 网站重定向到 https 网站,是否有像元或 JavaScript 或 html 这样的网站来执行此操作,我的网站有一个 http 服务器以及一个安全版本。
html ×3
javascript ×3
redirect ×2
asp.net ×1
c# ×1
django ×1
html-lists ×1
html5 ×1
ihttphandler ×1
jquery ×1
python ×1
security ×1
web ×1