FAQ - How to use a .htaccess to set your own redirect on your instance

DoliCloud is an open hosting solution. This means that, you can view, modify and download the program and data files. You can also edit files on your instances. Among this files, you can edit .htaccess files that are special files to allow you to define redirection directive on some Urls.





Create localy a .htaccess file


If you want to set a .htaccess file, the first step is to create it locally with any text editor (the name can't be modified).

Fill its content with a content to define the redirections you want to set. For example, for a .htaccess file to store into the .well-known directory of your instance:

RewriteEngine On
RewriteEngine ^oauth-authorization-server(/.*)?$ /custom/mymodule/oauth/mymoduleoauth.php [PT,L]
RewriteEngine ^openid-configuration(/.*)?$ /custom/mymodule/oauth/mymoduleopenid.php [PT,L]
RewriteEngine ^oauth-protected-resource(/.*)?$ /custom/mymodule/oauth/mymoduleoauthprotectedresource.php [PT,L]


Restriction on the use of .htaccess file


For security and performance reason, usage of a .htaccess is enabled only on the directory .well-known at the root of your instance.
If your need to set a .htaccess for another directory, you need to contact us from your customer dashboard, menu Support - Contact us, to ask us to enable the use of .htaccess on a larger surface of your instance.



Transfer the .htaccess files on your instance


To be able to transfer local files on your instance, you must use a file browser navigator that can connect to your instance using the SFTP protocol. Any SFTP software can be used for that. Take a look at the FAQ on how to use a SFTP client software to access files of your instance.

Use your SFTP client software to transfer the .htaccess file you built into the target director, .well-known in htdocs (you can create the repository with your SFTP software if you don't have it). As soon as the .htaccess file is stored in the directory, it has effect (if result is not as expected, just delete the file to cancel all your changes, this file does not exists by default).

Warning: Files and directories on your instances are in read-only mode by default, you must use the feature of your SFTP software to first set the permissions, on the files to replace, or the directories to write into, to set the file or directory in "Write allowed"mode.
Usually you can do this with a right click on the file from your SFTP client software. Then you will be able to overwrite the files with your own version of files.

 

 

 

FAQ written by the DoliCloud support team.