Question

I need help setting up the .htaccess for my DigitalOcean App Static Website

I created my static website with the new service called Apps, and I tried to add my .htaccess file, so the file gets uploaded and can be accessed by url through URL example.com/.htaccess but is not working on Digital Ocean and it’s not being executed.

I wonder what is the problem?

The .httaccess contains this:

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
ErrorDocument 404 https://mysite.com
ErrorDocument 500 https://mysite.com
RewriteCond %{HTTPS} !on 
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$ 
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$ 
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{THE_REQUEST} /([^.]+)\.html [NC]
RewriteRule ^ /%1 [NC,L,R]
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^ %{REQUEST_URI}.html [NC,L]


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Hello all,

Normally, if we were hosting the SPA ourselves then we’d have to configure Nginx or Apache to redirect all traffic to index.html

Static websites are not running apache or nginx so an .htaccess file won’t do.

There is a little workaround. Navigate to your SPA application under Apps in your Control Panel. Select the application you wish to make this change to.

Now go to the Settings tab, and scroll down to the bottom. There should be a section that says “Custom Pages”. Edit it, input “index.html” and save. Now wait for the redeployment to happen and it should work when you navigate to any paths!

Is there any update on this question? I cannot redirect my hugo website hosted by digitalocean app, from www to non-www.

Hi Akaben,

Static Sites on App Platform are not served by an apache server, so an .htaccess file will have no effect. What are you trying to accomplish with that configuration? We can help you find out if it’s possible with App Platform today and if so, help you achieve it.