A site i host is currently under construction so i am trying to redirect all pages back to the homepage. I am using the following code for redirection:
Response.Status = "302 Moved Temporary"
Response.AddHeader "Location", "http://www.soundczar.com"
Response.End()
However, the only browser that is able to redirect properly is Opera. Firefox, IE, and Chrome are unable to redirect the pages. I had the same issue last week with another classic asp site. I placed this code at the end of the footer SSI. Any suggestions?
By setting those in the footer, you are probably too late for most browsers -- you need it sent in the header, and headers will already be sent by then. Best to handle the condition before any page output happens.
If you can't do that, then you'll need to buffer the whole page, and clear the buffer before redirecting when you hit that condition:
Response.Buffer = True
Other_Code_Here()
If redirect_condition Then
Response.Clear
Response.Status = "302 Moved Temporary"
Response.AddHeader "Location", "http://www.soundczar.com"
Response.End()
End If
Related
I am trying to redirect using a button on a custom control (code below). the following is written to the debug toolbar which is where I want to go:
destBack=https://www.example.com/MyAttachments . But I instead get a Error 404 page and the following line appears on the server console:
HTTP Web Server: Item Not Found Exception [/site/home.nsf/https:/www.example.com/MyAttachments.xsp] Anonymous
I do have a reditection rule as follows:
Description: MyAttachmentsView
Type of rule: Redirection
Incoming URL pattern: */MyAttachments
Redirect to this URL: /site/home.nsf/MyProfileAttachmentsView.xsp
Send 301 Redirect:
If I copy and paste the destBack URL I get where I want to go.
My SSJS code behind the button is as follows
importPackage(com.example);
var destination = configBean.getValue("HostURL")+"MyAttachments";
dBar.info("destBack="+destination)
context.redirectToPage(destination)
Try this code to redirect
externalCtx = facesContext.getExternalContext();
externalCtx.redirect("http://www.tlcc.com");
See http://linqed.eu/2011/07/27/xpages-server-vs-client-side-redirects/
context.redirectToPage is designed to redirect the XPages runtime to an XPage within the current database. That's why the URL in the error message contains "/site/home.nsf/" (the current database path) and "https:/www.example.com/MyAttachments.xsp" (the URL you're defining).
If you want to change the whole URL, you need to change the URL client-side, not server-side, e.g. with location.href="...."
Sometimes during overload some sites fail to load.
I can detect this error using chrome.webRequest.onErrorOccurred api.
I guess the content script will not run at all in this case so sending message from background page to content script is of no use.
How can I paste a notice in the site body that it has failed to load?
Maybe using script execute from the background page? Will the page have a body content?
You've got a few options here. If you're using chrome.webRequest.onErrorOccurred() though I'd suggest you redirect the tab to an error page when an error occurs, using chrome.tabs.update().
For example:
chrome.webRequest.onErrorOccurred.addListener(function(details)
{
chrome.tabs.update(details.tabId, {url: "URL FOR AN ERROR PAGE"});
},
{types: ["main_frame"]});
This will redirect the tab the error occurred in when a web request with a resourceType of main_frame errors.
There are a few things you need to consider here. Do you only want to capture errors from requests with a type of main_frame? If not, just remove the 'types' filter from the event.
The other thing you need to consider is what page you're redirecting to. You can package a HTML file within your extension and then redirect to that. To generate the URL of your error page you can run chrome.extension.getURL('customerrorpage.html').
I have a problem where I load a URL in UIWebView. The URL redirects to a different location.
I handle this redirect with the following code:
- (NSURLRequest *)connection:(NSURLConnection *)inConnection willSendRequest:(NSURLRequest *)inRequest redirectResponse:(NSURLResponse *)inResponse {
if(inResponse) {
NSMutableURLRequest *req = [[inConnection originalRequest] mutableCopy];
[req setURL:[inRequest URL]];
return req;
}
return inRequest;
}
However, when the page loads, I get 404 on all the images. I can load the URL in Safari without any problems. This is happening on iOS6.1 and iOS7
I'm completely stumped as to what to do.
Unfortunately, I don't have access to the server, so I have to handle everything in my app.
Thanks for any advice.
Ah okay,
So what seems to have been happening, is that the my custom auth protocol was handling the initial request, then when the redirect request came in, a second caching protocol was intercepting the request for the images and breaking the redirect.
In the authprotocol, in the startLoading method I do the following:
[NSURLProtocol setProperty:#YES forKey:#"AuthSet" inRequest:newRequest];
So in the caching protocol's canInitWithRequest method I do the following:
if([NSURLProtocol propertyForKey:#"AuthSet" inRequest:request] != nil)
return NO;
Since, when we are caching, we have no need to follow redirects. So basically if the Auth protocol grabs the request, the caching protocol should not respond to it.
Will update after some testing to see if there are any other side effects.
I want to "proxy" web pages through a chrome-extension:// page (using an full-frame iframe), so that they show up as an extension page, instead of a webpage. I still want to apply content scripts to them, however, and have not had any success doing this. Is there a way to allow the chrome-extension page to access the contents of the iframe because it's "privileged" and should be allowed to get around XSS limitations?
Whenever I try to executeScript( { code : blah , allFrames: true }) I get an error about XSS about the chrome-extenion page, not the http page inside it...
Ideas?
I am using Joomla with IIS in my website, and now i am trying to set a 404 redirect page in my Joomla website, i could use htaccess to make this when i am using apache, but for this IIS its gets tricky it seems.
you can see my web.config file here
any suggestion would be helpful..
There is no module available AFAIK - at least not for 1.6. But it is quite easy to do by yourself. You can use the solution in the joomla documentation. This is usable for any error code.
http://docs.joomla.org/Creating_a_Custom_404_Error_Page
if (($this->error->code) == '404') {
header('Location: /search');
exit;
}
The part behind the Location: is where you redirect to the page you want. e.g. /search in this case. The above is for 1.5, for 1.6 you need to use this:
if ($this->error->getCode() == '404') {
header('Location: /search');
exit;
} ;
in your IIS Console, right click on the website, goto the Custom Errors TAB,
scroll down to HTTP Error 404, Edit Properties, change the Message Type
to URL, and then type in the URL you want to change to.