user10003651
user10003651

Reputation:

How do I redirect my github URL to the index file located within a folder?

The location at which my site ACTUALLY works: https://username.github.io/html/

The location at which I want my site to ACTUALLY work: http://username.github.io

Initially, I had my index.html directly in my repository, but then I moved it into an html folder with all my other html files for organization. How do I make it so it works in the following manner:

<head>
<title> NAME </title>
<meta name="viewport" content="width=device-width">
<link rel="shortcut icon" type="image/ico" href="/favicon.ico">
<link rel="stylesheet" href="../css/index.css">
</head>

<section id="Site">
<h3>
<a href="../html/">FIRST LAST </a>
</h3>
</section>

The location at which I want my site to ACTUALLY work: http://username.github.io

Thanks

Upvotes: 3

Views: 1431

Answers (2)

Sakura Kinomoto
Sakura Kinomoto

Reputation: 1884

Apparently, as you can read on github pages doc, you cannot configure it for having the "main page" on another place who aren't the root of repository, or a folder called docs.

As a workaround, you can try some options:

  1. You can try to use an .htaccess document, for configuring a 301 redirect. I didn't know if this can work on github pages, because I haven't use these service.
  2. You can try to put an index.htm on the root of the repository, and do a redirect from it. Check this code:

    <meta http-equiv="refresh" content="0; url=http://example.com/" />

If you need more information about how to do a redirect on html, check this question on SO: Redirect from an HTML page. But think, the redirect will only work for each file you create (for example, index.htm). And they only can have one destination. This option will not allow you to redirect any request to the page to the /html/ folder.

Upvotes: 1

ibn_Abubakre
ibn_Abubakre

Reputation: 112

You need to use the relative path to your index.html. So you'd have

<a href="../html/index.html">FIRST LAST</a>

Upvotes: 0

Related Questions