By saeeddarabi
Hi,
I am totally new to having my own server. So please bear with me if my questions are too simple for some of you.
I used ServerPilot to set everything up. Everything works great, but my www version doesn’t redirect to non www.
I have this code in my .htaccess file (which worked perfectly on shared hosting before - I assume because they were using Apache):
RewriteCond %{HTTP_HOST} ^www.example.com.se$ [NC]
RewriteRule ^(.*)$ http://example.com.se/$1 [R=301,L]
Now, my research shows that serverpilot uses nginx and that the above code doesn’t work for nginx. But then I read a guide on serverpilot that says they use nginx along with apache and that the htaccess code should work. But it is not working currently.
So I am very confused. I would appreciate any help on how to achieve this.
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!
Thanks this just helped me now. I guess I was using the old code, non-nginx code and it never caused an issue until just an hour ago. :O
But it’s all up and running now that I used that code instead. It was redirecting to /srv/… over and over in the URL box
Hi,
What you’re doing as well as those rewrite rules look correct. ServerPilot configures Nginx as a reverse proxy in front of Apache so you still can use .htaccess files exactly as you’re doing.
Please check to make sure you’ve added those RewriteRule/RewriteCond lines to the very top of your .htaccess file. If you’ve added them below other stuff (for example, below the WordPress stuff), they won’t work reliably.
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.