This documentation describes the usage of a previous web hosting offer proposed by Online.net.
Refer to the Scaleway Web Hosting documentation for information about the current web hosting product.
How to configure an .htaccess file on Web Hosting Classic
.htaccess
is a simple text file containing commands for configuring the Apache web server. It allows you to customize the server dynamically and per folder.
- When transferring your
.htaccess
file, ensure the FTP transfer mode is set to “ASCII/TEXT” and not “BINARY”. Transferring the file in binary mode will cause an HTTP error 500, blocking access to your websites. Also, ensure your.htaccess
file ends with an empty line to prevent this error. Double-check the file syntax before transferring it in text mode. - You can create the
.htaccess
file on Windows only using Notepad.
How to configure personalized error messages
You can replace the default 404 error (Not Found) message with a more user-friendly text or a redirection to another URL, either local or external.
- Use the
ErrorDocument
command to configure personalized messages. Here are some examples:ErrorDocument 404 /myfile404.htmlErrorDocument 404 http://URLexample.tldErrorDocument 403 /accessrefused.html - Place this command in an
.htaccess
file in the directory where you want to redirect the error messages. Typically, this is the root of your website.
How to disable directory listing
- Create an
.htaccess
file by opening your text editor. - Add the following line:
Options -Indexes
- Upload the file using FTP, place it in the desired directory, and rename it to
.htaccess
.
How to prevent access to a directory
- Open your text editor and create a file with the following lines:
# We authorize access from the IP 213.228.62.50Allow from 213.228.62.50# We authorize access from the IP 213.228.62.51Allow from 213.228.62.51# We deny access from all other IPsDeny from All
- Upload the file using FTP, place it in the desired directory, and rename it to
.htaccess
.
How to secure a directory with HTTP authentication
-
Create a user table with usernames and encrypted passwords. Here is an example:
martin:$apr1$tQqqRlvz$70soamNFTNl54OnSV.RWr.jean:$apr1$yMWZ093W$DKAVAi5.XRx1ofwF5T..E0sophie:$apr1$92x5vRxN$vivxTZtZfcqRmRBvL1ASF/Note- The first part is the username, and the second part after ”:” is the encrypted password. You can use this website to encrypt your passwords if needed.
-
Name this file passlist.txt.
-
Create an
.htaccess
file in the directory you want to protect, with the following content:AuthUserFile /flex/domain/DOMAIN.TLD/site/www/secret/password/mylist.txtAuthName "Access Restricted"AuthType Basicrequire valid-userImportant- Replace
PATH
with/flex/domain/DOMAIN.TLD/site/www/
. - Replace
DOMAIN.TLD
with your domain name.
- Replace
-
Upload the file using FTP, place it in the desired directory, and name it
.htaccess
. For more details, refer to the Apache user guide.
- It is not possible to create an
.htaccess
file directly on Windows. Create the file with another name (e.g.,htaccess.txt
) and rename it after uploading to your server. - Transfer the file in ASCII mode to preserve ‘line break’ characters.
- Protect your password list by storing it in a subdirectory and securing it with an
.htaccess
file.
How to configure HTTP redirections
- Create an
.htaccess
file with the following content:# Redirection to the site Scaleway.comRedirectPermanent / https://www.scaleway.com/en/ - Upload the file using FTP to the folder of the concerned subdomain (e.g.,
www
forwww.URLexample
,blog
forblog.URLexample
) and rename it to.htaccess
.TipFor more information, refer to the Apache documentation.
How to configure an HTML redirection
This method is simpler but less efficient. It uses the HTML document itself to indicate the redirection and should be used only when HTTP redirects are not possible.
Here is an example of redirecting http://old.address.fr/dossier1/URLexample/page1.html
to http://new.address.fr/dossier2/URLexample/page2.html
:
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="content-type" content="text/html; charset=UTF-8" /><meta http-equiv="refresh" content="0; url=http://new.address.fr/dossier2/URLexample/page2.html" /><title>Redirection</title><meta name="robots" content="noindex,follow" /></head><body><p><a href="http://new.address.fr/dossier2/URLexample/page2.html">Redirection</a></p></body></html>
How to configure PHP redirections
Create a PHP file with the following content to redirect http://URLexample/index.php/
to http://newsite.com/
:
<?phpheader("Location: http://newsite.com/");?>
- By default, the redirection returns the HTTP 301 status code. Modify it if required.
How to configure rewrite rules
- The Apache module
mod_rewrite
is activated on our web hosting servers and works by default with.htaccess
files. - The directive
FollowSymlinks
is activated and must not be modified, as doing so will result in an HTTP 500 error.
For example, to rewrite the URL http://www.URLexample/index.php/
with the page name as an argument:
- Create an
.htaccess
file with the following content:RewriteEngine OnRewriteRule ^([^\.]+)\.html /index.php?page=$1 [L] - Upload the file using FTP to the folder of the concerned subdomain (e.g.,
www
forwww.URLexample
,blog
forblog.URLexample
) and rename it.htaccess
. - Open the
http://www.URLexample/test.html/
file in your web browser. Theindex.php
file will be executed with the argument “test”.