XF 2.0 URL Canonicalization Test

SyTry

Well-known member
Hello,

Currently I'm doing some research on different sites to know the SEO criteria to improve it on my forum. I have a problem with URL Canonicalization :
Screenshot_1.webp

I use this code in my .htaccess :
Code:
RewriteCond %{HTTPS} off             
RewriteRule (.*) https://sytrycommunity.fr/$1 [R=301,L]

Here are the codes recommended by the site :
How to fix - URL Canonicalization Test
In order to pass this test you must consider using a 301 re-write rule in your .htaccess file so that both addresses (http://example.com and http://www.example.com) resolve to the same URL.
- If you want to redirect http://www.example.com to http://example.com, you can use this:
Code:
RewriteCond %{HTTP_HOST} ^www\.example\.com$
RewriteRule ^/?$ "http\:\/\/example\.com\/" [R=301,L]

- If you want to redirect http://example.com to http://www.example.com, you can use this:
Code:
RewriteCond %{HTTP_HOST} !^www.example.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]

Note that you must put the above lines somewhere after RewriteEngine On line.

Do I have to redirect the https://www.example.com to https://example.com ?
 
Thank you for your answers. I have enabled "Enable board URL canonicalization" but if I type https://www.example.com it does not redirect me to https://example.com. Did I forget something ?
 
Thank you for your answers. I have enabled "Enable board URL canonicalization" but if I type https://www.example.com it does not redirect me to https://example.com. Did I forget something ?
HTML:
    RewriteCond %{HTTPS} off
    RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
 
What are the server features you are using? Can you send me the .htaccess file codes you are using.
My host is 1&1 (Linux ). I use the original file, I only add the mod_gzip and this code :
Code:
RewriteCond %{HTTPS} off             
RewriteRule (.*) https://sytrycommunity.fr/$1 [R=301,L]

I just want my site to be accessible in HTTPS protocol without the WWW. So redirect the WWW to the without WWW. :unsure:
 
If I look at your site, I get the HTTP to HTTPS redirect. I don't get the www removal, but then the www version of your URL doesn't even resolve for me so it's not even getting to that point.
 
If I look at your site, I get the HTTP to HTTPS redirect. I don't get the www removal, but then the www version of your URL doesn't even resolve for me so it's not even getting to that point.
So what do I have to do to have a redirection from WWW to the without WWW ? Because the WWW version give an error and not a redirection :
Screenshot_1.webp
 
That's an issue with your site's DNS setup. You will likely need to talk to whoever manages your DNS (which may be your host), as you'll need to specify a rule for the www sub-domain (usually a CNAME), but the exact UI for this would vary quite a bit depending on how it's managed.
 
That's an issue with your site's DNS setup. You will likely need to talk to whoever manages your DNS (which may be your host), as you'll need to specify a rule for the www sub-domain (usually a CNAME), but the exact UI for this would vary quite a bit depending on how it's managed.
Ok thank you, this code is good or should I delete it :
Code:
RewriteCond %{HTTPS} off            
RewriteRule (.*) https://sytrycommunity.fr/$1 [R=301,L]

EDIT : https://xenforo.com/community/threa...-not-defined-htaccess-ssl.134741/post-1178063
 
Last edited:
If you have the board URL canonicalization option enabled, it shouldn't be necessary.

Note that code is more about HTTPS detection than www removal.
 
The feature was introduced fairly recently, so it's optional.

If your site already redirects to a single canonical URL (not everyone's does) then it's not needed.
 
Top Bottom