Overview
This article provides guidance on creating a custom configuration file to force a redirect to the secure HTTPS version of your website's URL.
Adding custom code is only necessary if your website requires specific code to force the redirect.
When you add an SSL certificate to your website in the panel, DreamHost automatically redirects the URL visitors use to view your site from HTTP to HTTPS. The S ensures that your connection is encrypted (e.g., https://example.com).
There's nothing on your end you must do in order to force your site to use the secure URL but there may be special cases where it may be required for you to force the redirect using a custom configuration file.
FAQs
When would I need to create a custom redirect?
-
In special cases, you may need to create your own custom configuration file to force a redirect.
For example, if your website is custom-built, it may require special considerations for all URL redirects. In a unique situation like this, you would need to add custom code to force the redirect to HTTPS within a configuration file.
The name and location of the custom configuration file is dependent on the software your website uses and the operating system of your web server, such as Apache or Nginx.
How do I know if I need to create a custom redirect?
-
You would need to contact a web developer or consult the documentation for the software your website is using. Again, this is a very rare situation that does not apply to the majority of websites.
Can I use the Redirect service in the panel to force HTTPS?
-
It is not possible to use the panel's redirect service to force your site to load the HTTPS version of its URL. This is because the HTTPS service only functions when the site is Fully Hosted, and the Redirect service removes hosting from the domain.
How to create a custom configuration file
There are three steps to creating this file.
Confirming you need a custom file
As stated above, the majority of websites can use the panel redirect option without issue. If for some reason this is not functioning as intended, consult a web developer or the official documentation of the software your website is using. Only after confirming this is necessary should you proceed.
Disabling the panel redirect
The next step is to disable the automatic redirect in your panel. See this article for instructions on how to remove the DreamHost service that automatically redirects your site to HTTPS.
When the DreamHost redirect is no longer active, only your custom code will control the redirect to the HTTPS version of your site.
Creating the custom redirect file
To create this file, you must log in to your server via FTP or SSH.
Apache servers
-
The majority of all DreamHost customers are running their site on an Apache server. In this case, you'd just need to create an .htaccess file for your site.
Nginx servers
-
Unless you've manually changed your VPS or Dedicated Server to run Nginx, you are using Apache.
Nginx servers require you to create a redirects.conf file. See this article for further information.