My site dns is setup correctly to point all non “www” to www. For example all urls should be www.mikecapson.com. However I am having issues as the Grav install seems to be forcing it without the www. Also I can reach internal images the way it is now however if I add in the www to the url I get a 404 for images. I’m not sure the area to check to resolve this issue. I have checked the htacces and didn’t notice anything unusual.
My install is installed in a vhost under var/vhost/mikecapson.com/installedhere
Any help would be appreciated.
Do you have a public URL i can look at? And how exactly is your
www. url being redirected to
non-www. ? Is this an .htaccess thing? or purely a DNS thing?
mikecapson.com is the public url. My dns is handling the redirect.
Ok, so just for clarity. http://mikecapson.com does not redirect, to http://www.mikecapson.com, it just seems to be an alias to www. Grav get’s the hostname for URLs directly from PHP’s
$_SERVER['SERVER_NAME'] variable, and that is usually the same as the URL in the browser.
The best way to ensure that PHP has the correct name is to actually do a redirect rather than alias. Here you can see how to use .htaccess to redirect non-www to www URLs: http://dense13.com/blog/2008/02/27/redirecting-non-www-to-www-with-htaccess/
Grav linking to the full URL is a little strange, and i"m trying to work out why that is doing that. Let’s use your navigation as an example. How exactly are you outputting your navigation menu? This theme is customized so I need to know how the page URLs are being generated. Then we can proceed with tracking it down why those are full and not relative…
To be specific I really need to see the content of your twig template that is outputting the menu.
BTW, we think we may of found an issue either directly causing your issue, or closely related, so we’re investigating it.
OK we’ve fixed a couple of config caching bugs and pushed them to GitHub. However, i’m not convinced this is the cause of your issue. Could you first upgrade your Grav to 0.9.5 as your still on 0.9.4?
Easiest way is to do it via GPM from the command line (if possible):
This will update Grav to latest version first, then the plugins and themes.
Iv updated to 0.9.5, i have implemented the redirect in my .htaccess to force the www.
In my theme the nav is hardcoded like below and works properly once the .htaccess was implemented:
Also this seems to have fixed the issues with linking as I had asked above.
Thanks for the support!
Ok awesome! One thing you might want to do is replace
base_url_relative to save a little space and make things cleaner.