1. .htaccess on GitHub Pages:

What does .htaccess my site look like on GitHub Pages:

 # Переадресация index.html на заглавную RewriteEngine On RewriteCond %{THE_REQUEST} ^[AZ]{3,9}\ /index\.html\ HTTP/ RewriteRule ^index\.html$ http://Kristinita.imtqy.com/ [R=301,L] # Скрытие расширений .html RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}.html -f RewriteRule ^(.*)$ $1.html # Кастомная страница 404 ErrorDocument 404 /404.html 

The contents of index.html on the title page, the extensions are hidden, on error 404 my custom page is shown.

2. Question

Do .htaccess rules apply to sites on GitHub Pages? After all, GitHub Pages is only a hosting for static sites.

  • GitHub pages is not exactly hosting, so you can hardly configure it flexibly. It is intended in principle to store as a maximum of html + css + javacript - Prvz
  • one
    (1) I have already said everything about the github-pages tag, I can only add that the number of questions on the tag is either on another web site or here is not an argument in its favor: Experienced participants were sometimes forced to edit hundreds of questions to remove frankly garbage tags, such as programming , since even moderators do not have tools for bulk editing tags, except for synonyms, which are not always applicable. (2) Images are inserted into questions when it is easier to show something than to describe. In your case, the images only duplicate the text and inflate the question. - Risto

1 answer 1

1. Answer

poorly GitHub Pages server settings are different from Apache server settings. .htaccess and httpd.conf on GitHub Pages do not apply.


2. Justification

Marketing GitHub is a very popular resource; if there is any functionality, they probably would have written about it on the official website. And nothing is written about Apache on GitHub. It is unlikely that marketers would have made such an omission.

You can try to test some .htaccess rules on GitHub Pages. Suppose to hide the directory from the URL :

 RewriteRule ^folder/(.+)$ http://www.sashagoddess.com/ [R=301,L] 

or displaying a custom html file on the main page of the site :

 DirectoryIndex SashaPrettyWoman.html 

These rules will not work.


3. Replacement

Replacement Why did this question even arise? I made the .htaccess settings on the WAMP server → transferred the site to GitHub Pages → everything worked, I was convinced that it was because of my .htaccess . However, in reality .htaccess nothing to do with it:

1. index.html in the root folder of the site on the capital

So that when you go to the main page of the site, for example, http://sashagoddess.com , the contents of the http://sashagoddess.com/index.html file would be displayed. This is on GitHub Pages by default .

2. Hiding the .html extension in the URL

So that when you go to http://sashagoddess.com/sashafantastic the same page would open as when opening the URL http://sashagoddess.com/sashafantastic.html . Also available by default .

3. Custom 404 Error Page

Configured differently .


On GitHub Pages in some cases it is quite possible to find a replacement for the .htaccess rules.