Question
.htaccess not working for Ghost Droplet
I’m having difficulty running my .htaccess file within my Ghost droplet. I have an .htaccess file with the following commands to redirect non-www requests to www requests, but a redirect is not happening:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
I also tried the nginx server workaround, but got a continuous loop error with the redirect script and have a CNAME with www and mywebsitedomain. Any thoughts as to why this redirect isn’t happening?
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.
×
Hi,
Please try out the following command -
RewriteEngine On
RewriteCond %{HTTP_HOST} domain.com [NC]
RewriteRule (.*) http://www.domain.com/$1 [L,R=301]
Add the above code to you .htaccess file and replace domain.com with your domain name.