WebGL link to new tab opens to error 404

Hi, I am making a WebGL game to be played in browsers, I have a button that I want to open a new tab to a webpage when clicked. I am successfully opening to a new tab, however getting error 404 page. The url in the browser reads like this:

https://“Website Game Is Hosted”/tmp/5959000/5959937/file/alternate/alternate_2_r1.zip/“website Im Trying to Link to”

I’m using the method explained in this Youtube tutorial:

I did install the plugin just as the video instructs,
Here is my code:

using UnityEngine
using System.Runtime.InteropServices;
public class OpenLink : MonoBehaviour
{
public static void OpenURL(string url)
{
#if !UNITY_EDITOR && UNITY_WEBGL
OpenTab(url);
#endif
}
[DllImport(“__Internal”)]
private static extern void OpenTab(string irl);
}

It seems odd that the 404 shows the name of the site I want to link but still gives me the 404, almost like it is blocking permission to go to that website.

Anyway I appreciate anyone who might have some insights on this, thanks.

Putting this post in scripting section for lack of a better option, apologies if it is in the wrong section.

It’s difficult to be any help here because you obfuscated your URL to a point we can’t really say what you actually want to link here. That’s fine when you don’t want to reveal details about your host or project. However it’s difficult to make much sense of it. A 404 response from the server indicates that the server can not find the requested resource. We don’t know what hoster you use. Some cheap hosters often inject bot protection javascript stuff into your own sites you’re hosting.

Debugging has to be done by you. Open your browser development tools, watch the network tab what urls gets requested. You can also inspect what files / resources get loaded from your server. A path like “tmp/5959000/5959937/file…” looks like some kind of CMS stuff and may not be the correct URL. Have you actually tried to use the URL you try to open manually in a browser? Does it work?

If you can not share details of your hoster or project, at least present us a proper example. Feel free to use “example.com” but stick as close as possible to what you’re doing. What do you exactly pass to your OpenURL method and what’s the URL in the tab that opens. Are there any redirects happening?

ps: If you don’t need some kind of server side scripting but just a simple host for web content, you could even use github pages. I have all my WebGL examples hosted there.

I figured out the issue and will post an answer here for anyone else who may have the same issue. I was simply using (example) www.google.com instead of https://www.google.com/

so, https:// is required in order the open the link properly.

1 Like

Thank you for taking the time, you have encouraged me to make sure to provide as many details as possible when asking questions and to read the Unity documentation before posting in the future. I figured out my problem and posted it below for others who may have the same issue.