How can I make my site only work on my main URL?

I want to make my website a rickroll if its not on the main site (ples-nerd.bluebaystudios.repl.co).

What is “my URL”? You could use some JavaScript

const myURL = "https://example.com";

if (location.href !== myURL) {
  location.replace("https://www.youtube.com/watch?v=dQw4w9WgXcQ");
}

When I go to the site, it just redirects me either way.
Edit: i did replace the link btw

Well did you set myURL to the URL you’re talking about?

Yes,I changed it to ples-nerd—bluebaystudios.repl.co, and also tried changing — to . Can I make it a specific site I dont want it to be on?

You set myURL to the wrong link. You set it to https://plesnerd--bluebaystudios.repl.co instead of https://ples-nerd--bluebaystudios.repl.co.

It still just redirects me. Weird.

You didn’t include the https://.

Doesn’t work :frowning:. Maybe it ridirects the - - and the . Links? So we can have two values(if this is possible?)

Try

const myURL = "https://ples-nerd.bluebaystudios.repl.co";

if (location.href != myURL) {
  location.replace("https://www.youtube.com/watch?v=dQw4w9WgXcQ");
}

Is the code redirecting if the link is the main lin? Either way, it is Still is not working. Can I have it not work for a certain site?

No.

Yes, but can you try this first:

const myURL = "https://ples-nerd.bluebaystudios.repl.co/";

if (location.href != myURL) {
  location.replace("https://www.youtube.com/watch?v=dQw4w9WgXcQ");
}

And make sure you’re opening in a new tab.

Works great! Only problem is, the site(I helped with it, then stopped and did not give permission to use my game)that is using my game uses google sites, and it’s not working. GingerLynx - Ples Nerd

Because that site iframes your “main URL”

@BluebayStudios try this:

if (location.href != myURL || window.parent.location == "https://www.gingerlynx.com/ples-nerd/") {

It kind of freezes the page, which works, but I want the rickroll :laughing:

Well that’s because you can’t iFrame most sites, including YouTube, as it would be a security risk, so you could embed it instead:

location.replace("https://www.youtube.com/embed/K0aRrQJfxZI?si=Pw9LR9jNNPcvX6Ar");

Can i embed https://rickroll-web-template.bluebaystudios.repl.co/?

Yeah

location.replace("https://rickroll-web-template.bluebaystudios.repl.co/");

Also, you’re* (on the site)

You’ll have to turn it into an Express server using Node.js, and then use app.use() to detect when the user goes to any URL other than your main one.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.