How to redirect only the root path in nginx?
I got it. location ~ ^/$ { return 301 https://www.b.com/; }
I got it. location ~ ^/$ { return 301 https://www.b.com/; }
Setting the error page to the home page like this error_page 404 /index.html; has a small problem, the status code of the home page will be “404 not found”, if you want to load the home page with a “200 ok” status code you should do it like this error_page 404 =200 /index.html; This will … Read more
It shouldn’t be cached at all unless there’s also a Cache-Control or Expires header returned by the web server. According to RFC 2616, section 10.3.3 302 Found The requested resource resides temporarily under a different URI. Since the redirection might be altered on occasion, the client SHOULD continue to use the Request-URI for future requests. … Read more
I use spring 3.2.3 and here is how I solved similar problem. 1) Added RedirectAttributes redirectAttributes to the method parameter list in controller 1. public String controlMapping1( @ModelAttribute(“mapping1Form”) final Object mapping1FormObject, final BindingResult mapping1BindingResult, final Model model, final RedirectAttributes redirectAttributes) 2) Inside the method added code to add flash attribute to redirectAttributes redirectAttributes.addFlashAttribute(“mapping1Form”, mapping1FormObject); 3) … Read more
As stated in the nginx pitfalls you should use server blocks and return statements as they’re way faster than evaluating RegEx via location blocks. Since you’re forcing the rewrite rule to send a 301 there’s no difference when it comes to SEO, btw..
I had this same problem before. Because Nginx can’t do complex conditions or nested if statements, you need to evaluate over 2 different expressions. set a variable to some binary value then enable if either condition is true in 2 different if statements: set $my_var 0; if ($host=”domain.example”) { set $my_var 1; } if ($host=”domain2.example”) … Read more
Bringing this topic back from the dead to mention that GH now supports redirect-from’s redirect-to parameter https://github.com/jekyll/jekyll-redirect-from#redirect-to Simply add this to your _config.yml gems: – jekyll-redirect-from And this to the top of your index page. — redirect_to: “http://example.com” —
This can be achieved by adding the redirect path in the route as a query parameter. Then when you login, you have to check if the redirect parameter is set: if IS set redirect to the path found in param if is NOT set you can fallback on root. Put an action to your link … Read more
You could make www.example.com the A record and all the other domainnames CNAMEs of www.example.com. But this only “solves” that if the IP address of www.example.com changes you don’t have to alter the other DNS enties as they are aliases. So on the DNS level there is no way to enforce a redirect. And for … Read more