How do I force redirect all 404’s (or every page, whether invalid or not) to the homepage?

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

How long is a 302 redirect saved in browser?

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

How to pass model attributes from one Spring MVC controller to another controller?

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

nginx.conf redirect multiple conditions

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

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)