Custom font load with www and without www


#1

When I watch my site on www.domain.be (with any page after it, like for example www.domain.be/error-404) all fonts are loaded and shown correctly.
If I watch the pages like domain.be (and domain.be/error-404) the fonts don’t load correct: they just show times new roman or verdana or something standard.

I use
<base href="http://www.domain.be/">

If I change this to
<base href="http://domain.be/">
than the font-problem is reversed…

(If I don’t use base href my css-file doesn’t load.)
<link rel="stylesheet" href="css/main.css" type="text/css" media="screen" />


#2

That’s quite weird, it shouldn’t require a <base> line at all. Have you tested this in other browsers or on a phone or other device?


#3

Same thing in all browsers I checked.
Without the base-line it doesn’t show images too.


#4

yes it now working fine but i getsome error


#5

To solve this I just wanted to redirect any non-www page to www with htaccess

I had these lines in there to redirect https to http.

RewriteBase /
RewriteEngine on

RewriteCond %{HTTPS} on
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI}

I changed it to this lines I found on internet (assuming this would redirect non-www to www and keep redirecting https to http - but it doesn’t do the latter).

RewriteBase /
RewriteEngine on

RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{HTTPS}s on(s)|offs()
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [NE,L,R]

Any help to make it both work?


#6

So, there’s a reason why the code you’re using isn’t working — the browser wants to redirect a HTTPS-based version of the site to www, and then to HTTP. It’s going to run into a problem because of a certificate mismatch issue.

What I suggest is following my tutorial on using Cloudflare to enable HTTPS on your custom domain, then updating your .htaccess to redirect HTTP to HTTPS (and then non-www to www).

RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

By doing this, you’ll not only have a more secure website, but your redirection issue should be fixed and your fonts should load fine. You’ll have to use the following for your <base> line.

<base href="https://www.example.com" />

#7

Thanks for the advice but it seems like this is gonna take a while, and I’ve already spent so many frustrating hours on that site (at the moment it’s not even fun anymore).

No way anyone could for now, just make this htaccess lines work for base line http://www.example.com ?
So https to http and non-www to www.
Anyone?


#8

@BegEnd What is your domain/website name??