By akaben
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]
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!
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.
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!
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.