Quotidien Shaarli

Tous les liens d'un jour sur une page.

January 2, 2022

Médiathèque - Les Défis du CEA

Bimestriel - Les Défis du CEA

Note: Astuces pour l'hébergement web - htaccess
RewriteEngine on

## Force HTTPS
## RewriteCond %{HTTPS} !=on
## Alternative if the line above doesn’t work.
RewriteCond %{SERVER_PORT} 80
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301]

## Removes www.
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ https://%1%{REQUEST_URI} [R=301,L]

## Disable directory listing
Options -Indexes

## Security
# Block access to all hidden files and directories except for the visible content from within the `/.well-known/` hidden directory.
RewriteCond %{REQUEST_URI} "!(^|/)\.well-known/([^./]+./?)+$" [NC]
RewriteCond %{SCRIPT_FILENAME} -d [OR]
RewriteCond %{SCRIPT_FILENAME} -f
RewriteRule "(^|/)\." - [F]

# Block access to files that can expose sensitive information.
<FilesMatch "(^#.*#|\.(bak|conf|dist|fla|in[ci]|log|orig|psd|sh|sql|sw[op])|~)$">
Require all denied
</FilesMatch>

# Deny Access to .htaccess
# <Files .htaccess>
# Order Allow,Deny
# Deny from all
# </Files>

## Page de maintenance
RewriteCond %{DOCUMENT_ROOT}/maintenance.on -f
RewriteCond %{REQUEST_URI} !/en-maintenance\.html$
## For including image inside
## RewriteCond %{REQUEST_URI} !\.(jpe?g?|png|gif) [NC]
RewriteRule .* https://nerneste.fr/en-maintenance.html [R=302,L]

Notes :

YOURLS installed on root : If YOURLS root URL is https://yoursite.com/ or https://subdomain.yoursite.com/, the .htaccess file in the root directory must be like RewriteBase /.
YOURLS installed in subdirectory : If YOURLS root URL is https://yoursite.com/somedir/, the .htaccess file in this subdirectory must be like RewriteBase /somedir/.

Sources :