clubmate.fi

A good[ish] website

Web development blog, loads of UI and JavaScript topics

Different ways to redirect URL

Filed under: Server— Tagged with: .htaccess, apache, nginx, snippets

A quick guide on redirection with Apache, NGINX or just plain HTML.

Apache

A very robust way of redirecting. Just paste this in your .htaccess file:

Redirect 301 / http://clubmate.fi/

NGINX

Paste this in your NGINX server block, or into a nginx.conf file in your projects root.

server {
  # Direct this address...
  server_name example.com;

  # ...to this address
  return 301 $scheme://example.net$request_uri;
}

Using meta redirect

A bit more "lighter" method with timing. Paste this inside your head tag.

<meta http-equiv="refresh" content="0; url=http://clubmate.fi/" />

That 0 is a time (in seconds) how long the browser waits for the redirect.

Comments would go here, but the commenting system isn’t ready yet, sorry. Tweet me @hiljaa if you want to make a correction etc.

  • © 2021 Antti Hiljá
  • About
  • Follow me in Twatter → @hiljaa
  • All rights reserved yadda yadda.
  • I can put just about anything here, no one reads the footer anyways.
  • I love u!