By nickbernier
I previously had my blog urls at http://www.domain.com/category_name/post_name/ it has now moved to http://blog.domain.com/category_name/post_name/
The main website used to be at http://www.domain.com/main/ and it is now simply at the root http://domain.com.
I have separate sites-available conf files for the main site and the blog.
I have searched high and low and cannot find anything that seems to work to redirect the incoming urls?
I’m using Ubuntu 12.04 LTS, nginx version installed is 1.1.19
Any help would be greatly appreciated!
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!
You can redirect www.domain.com/ to domain.com and www.domain.com/* to blog.domain.com - are you okay with that?
I’ve tried that and it was not working for. I actually couldn’t get anything to work other than the redirect 301 to redirect www.domain.com to domain.com. I’ve tried rewrites and location rewrite blocks and none work. Is there an additional step to take to enable rewrites in nginx its like they are disabled or the module isn’t installed? <br> <br>Anybody else having redirect issues with stock nginx in the Ubuntu 12.04 32bit?
Try these rules: <br> <br>(in www.domain.com’s server block) <br> <br>rewrite ^/$ http://domain.com permanent break; <br>rewrite ^/main(.)$ http://domain.com$1 permanent break; <br>rewrite ^(.)$ http://blog.domain.com$1 permanent; <br> <br>Make sure you reload nginx. <br> <br>With this config: <br> <br>- http://www.domain.com/ redirects to http://domain.com <br>- http://www.domain.com/main/something redirects to http://domain.com/something <br>- Everything else redirects to http://blog.domain.com/ <br> <br>Let me know how it works for you! :]
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.