glFusion Wiki

Site Tools


URL Redirection

When you initially install glFusion, you configured a Site URL setting. We want to make sure that if you site is accessible through multiple URLs, that we always redirect to the URL setup in Site URL.

Many shared hosting providers allow access to a site by using both (notice the missing www) and

I always just type the root domain, But for sites that I manage I choose to be canonical – mainly because in print it’s best to use the www. address as it’s easy to pick out as a web address. For .com’s this isn’t as important as for .org or .net, IMO, as nowadays most people recognise that “.com” refers to a website.

Why This is Important

glFusion utilizes Cross Site Request Forgery (CSRF) protections that validate the referring URL to the configured URL. If they do not match, the request is not executed. If you can access a site through multiple URLs, there is a possibility that requests will fail the CSRF check. For example, when logging into a site, is not equal to

glFusion also uses the full URL when creating links to style sheets (.css) and JavaScript (.js) files. Modern browsers will block access to some of these files or images when the URLs are not matched.

Another reason why it is preferable to only allow access via a single URL is search engines. If there are multiple URLs, you are showing the same content to the search engines under more than one URL. In other words, your site is serving up duplicate content.

The problem is that search engines have to choose *one* of those copies, and declare it to be the official “canonical” URL.

Setting Up Redirection using .htaccess

Add the following to your .htaccess file

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
RewriteRule ^(.*)$$1 [R=301,L]

This will redirect all addresses that don’t start to

Setting Up Redirection in Nginx Web Server

If you want redirect users from a plain, non-www domain to a www domain, add this server block:

server {
  return 301 $scheme://$request_uri;

Save and exit. This configures Nginx to redirect requests to to <nowiki></wowiki>. Note that there should be another server block that defines your www web server.

To put the changes into effect, restart Nginx:

sudo systemctl restart nginx
2017/03/10 07:22 · mark
glfusion/installation/redirect.txt · Last modified: 2017/03/10 01:23 (external edit)

Page Tools