raf
raf

Reputation: 255

Redirect the domain including all subdirectories

Suppose, my website is originally published at x.github.io. And I have another website y.github.io. My target is to redirect from 2nd one to the original one.

I like to redirect the subdirectories too such that when y.github.io/cv is visited, it should redirect to the page x.github.io/cv. How can I do it effectively?


For now, I am making it work by creating a subdirectory cv in the repository of y.github.io and adding the following index.html file in it:

/y.github.io
.
├── cv
│   └── index.html (2)
└── index.html (1)

index.html (1)

<!DOCTYPE html>
<html lang="en">
<body>
    <script>
        window.location.replace("https://x.github.io/")
    </script> 
</body>
</html>

index.html (2)

<!DOCTYPE html>
<html lang="en">
<body>
    <script>
        window.location.replace("https://x.github.io/cv/")
    </script> 
</body>
</html>

But I don't prefer this method. Instead, I like to configure it so that I won't have to update the repository of y.github.io each time I create any new subdirectory in the repository x.github.io.

Upvotes: 0

Views: 46

Answers (0)

Related Questions