Boxes on the new Raidboxes 2.0 infrastructure use .htaccess files that can be edited by you.
If you still have Boxes on the old infrastructure, .htaccess files have no function as they are ignored by NGINX web servers. You can find more information in our article: Do you support .htaccess files?
What is .htaccess?
The .htaccess file is a configuration file for web servers that use the Apache HTTP Server module. It allows you to set server-side directives for specific directories, such as redirects, password protection, or caching.
The .htaccess file already contains important instructions for the functionality and security of your WordPress installation. These standard instructions should not be changed or deleted without sufficient knowledge, as incorrect changes can affect the functionality of your website.
Where can I find the .htaccess file and how can I edit it?
The .htaccess file is located in the root directory of your WordPress installation. To edit it, you can use an FTP client like FileZilla or log into the box via SSH to edit it directly. Note that various plugins can also automatically write entries to the .htaccess file to enable certain functions.
How do I set up redirects?
To set up redirects in your .htaccess file, add the following code below the existing instructions:
# Internal redirect
Redirect 301 /old-page /new-page
# External redirect
Redirect 301 /old-page https://www.external-site.com
This command permanently redirects all requests from /old-page to /new-page or https://www.external-site.com. You can define multiple redirects by adding more entries.
Please note that redirects can also be configured via the Raidboxes dashboard. These have a higher priority than the redirects defined in the .htaccess file. For more information, see our Redirects (Forwarding) article.
Experienced users can find additional information and advanced techniques for URL rewriting and redirects in the official Apache documentation.
How can I protect directories?
To password-protect a directory, you need to create a .htpasswd file that contains the usernames and encrypted passwords. Then, add the following code to your .htaccess file:
AuthType Basic
AuthName "Protected Area"
AuthUserFile /path/to/.htpasswd
Require valid-user
This code prompts users to enter a password before they can access the directory. For detailed instructions, read our Protect a directory with .htaccess article.
Backup of the .htaccess file
We always keep a .htaccess.backup file available. This contains the standard configuration and can be restored or used for comparison if needed. This helps you undo unwanted changes and ensure that your website continues to function properly.
The .htaccess file offers many more ways to customize your WordPress website. Use it wisely and thoroughly test changes to avoid unwanted effects.
If you are unsure about any of the topics described above, please contact your web developer or our support team.
