I have a site that needs to show the main website for screen widths down to 480, then switch to a mobile site. The original site is too tough to reverse responsive so this is what I came up with and it works, except it needs to be improved because it doesnt react to the rotation of the device. On large phones in landscape the main site should show and then back to the mobile in portrait. Everything I have tried has broken what I do have working. Any ideas how to modify this to react to device rotation, would be much appreciated.
<script type="text/javascript">
$(document).ready(function(){
if($(window).width() < 480){
window.location = "http://mobile"
}
});
</script>