Http error 302 means taht your web server thinks that your url has been temporarily redirected to another url. I stumbled this error last week while working on a project and I couldn’t figure out what was wrong. Like many other developers, I was working locally and each time I tested the website, I never saw this error.
I noticed that this error would only be generated by my ajax calls.
Turns out that fixing this error is quite simple. The real problem lies in your url address. Locally, you address never changes; however, once online, there’s two ways to reach your website. In this case, we have www.codinginsight.com and codinginsight.com. So one url has www, the other not.
The solution here is to tell your server to redirect all non www link to your full www address. Since most web server are using Apache, we can use htaccess to do our redirection. You can use an online generator to do that for you.
Your htaccess should have the following lines
//Rewrite to www RewriteEngine on RewriteCond %{HTTP_HOST} ^domainename.com[nc] RewriteRule ^(.*)$ http://www.domainename.com/$1 [r=301,nc
Once that’s set, no more error 302!!! Yay!!!!
The post Fixing HTTP Error 302 appeared first on Coding Insight.