How and where to define BASE_URL in 5.7

What's the best way to ensure that my base url includes www?

View Replies: View Best Answer
Chrouglas replied on at Permalink Reply
I'd love to see an answer for this since site.php is no longer in existence in 5.7.

I have a rather large site in development and I want to make sure I don't need to change all the links within 'content' blocks when it goes live. Will setting base_url solve this? Or is there a way to have links within content block always be relative?
zanedev replied on at Permalink Reply
Does anybody have any idea how to get all links to be relative like the old 5.6 version? It was one of the features I loved about C5, I didn't have to go through the db file and replace all the urls when going live. I've found that setting the canonical url to the relative url works for page links but ajax requests in the dashboard like sitemap attributes menus are not using the relative (canonical) url
zanedev replied on at Permalink Reply
Whoops nevermind it still works like it used to you just set DIR_REL like you used to, put it in one of your configs:

define('BASE_URL', 'http://localhost');
define('DIR_REL', '/mydirrel');
iwmconcrete replied on at Permalink Reply
Which 'config' exactly?
mhawke replied on at Permalink Best Answer Reply
I just add this to my .htaccess file:
RewriteCond %{HTTP_HOST} ^ [NC]
RewriteRule ^(.*)$$1 [L,R=301]

Of course you need to replace the '' part with your own domain name.
barkingtuna replied on at Permalink Reply
Can you explain this using the following example? I built the site here, under the following domain and subdirectory and the final live site is here, at I need all of the traffic to redirect to the live/permanent site at
iwmconcrete replied on at Permalink Reply
That's the way I've always done it in 5.6, but not working for me in 5.7 anymore.
ob7dev replied on at Permalink Reply
For 5.7:
In the URL settings in the dashboard you can set the canonical URL to include the www, and then check the box for only using canonical URLs and save your changes. The site will then always redirect to the www before your site.