Absolute url with the www

Continuing the discussion from Force absolute links? Relative links are bad practice for SEO:

I’m trying to remove all www versions of my site. I was able to do so with a few simple htaccess rules, but for some reason, the absolute url returned from $page->url() includes a www at the beginning. Where do I control what kind of absolute links Kirby produces (www vs non-www)?

Have you tried to set the URL in your config.php?

c::set('url', 'http://yourdomain.com');
1 Like

Thanks Texnixe! That was it!

One more thing…

If I set the url in the overall config.php file it works, but if messes with my links in my development setup (of course). So I tried to add a domain specific config file, e.g. config.mysite.com.php and it didn’t work. I have to include the www in the name of the config file, e.g. config.www.mysite.com.php in order for any of the customizations in the file to apply to the live site.

What am I doing wrong?

The filename of the used host-specific config files is based on the $_SERVER['SERVER_NAME'] and SERVER_ADDR variables. Could you please check what these are set to by using dump($_SERVER)?

Do you use a dedicated server or do you use a shared hosting provider? What are your domain settings?

@lukasbestle I ran the var_dump($_SERVER) and it did show the www prefix on my url in the SERVER_NAME. The SERVER_ADDR was an ip address. Do I need to change these somewhere?

@texnixe I use a shared hosting provider. What kind of domain settings should I provide?


Even when visiting the site without www? Then it’s most likely a configuration issue in the hosting provider’s system. They should be able to correct this.

Yes, even when visiting it without the www. I’ll talk to my hosting provider. Thanks for your help!