Firstly, give your "weather" section an id
<div id="weather">
<!-- weather content -->
</div>
Voila! Visit mydomain.com/#weather
now. The browser should scroll you to corresponding element. This also applied to anchor tag
<a href="#weather">Weather</a>
Implementing animation
Suppose you're going to apply scroll animation when certain element clicked
<a class="to-weather" href="javascript:void(0);">See weather here</a>
<button type="button" class="to-weather">See weather here</button>
with jQuery
$('.to-weather').on('click', function(e) {
e.preventDefault();
$('html, body').animate({
scrollTop: $("#weather").offset().top
}, slow);
});
Redirect
Either .htaccess and PHP both can handle redirection
.htaccess
RewriteEngine On
RewriteRule ^weather$ /#weather$ [R=301,NE,L]
PHP
header("Location: /#weather", true, 301);
Implementing animation
A hacky solution but works. First, Set the #weather
on element on topper area of document such as body
<body id="weather">
Browser will stayed at top as the id its bound to is on body tag. And once document is ready, you can do scrolling animation to desired element with just a simple validation. I'll name it #weather-area
$(document).ready(function() {
//Not all browser contains # in location.hash
var hash = location.hash.replace('#', '');
if(hash === 'weather') {
$('html, body').animate({
scrollTop: $('#weather-area').offset().top
}, 3000);
}
});