EE Insider Tips
Sponsored by Mijingo's EE 2 Screencasts
ExpressionEngine mini-howtos created by the EE Insider community.
Dynamic paths in config.php
It’s possible to update your config.php file to automatically generate lots of (but sadly not all) paths used by the software. Here’s what I use:
$conf['site_url'] = "http://${_SERVER['HTTP_HOST']}/";
$conf['cp_url'] = "http://${_SERVER['HTTP_HOST']}/${conf['system_folder']}/";
$conf['tmpl_file_basepath'] = "${_SERVER['DOCUMENT_ROOT']}/_template/";
$conf['theme_folder_path'] = "${_SERVER['DOCUMENT_ROOT']}/themes/";
$conf['theme_folder_url'] = "http://${_SERVER['HTTP_HOST']}/themes/";
$conf['captcha_path'] = "${_SERVER['DOCUMENT_ROOT']}/images/captchas/";
$conf['captcha_url'] = "http://${_SERVER['HTTP_HOST']}/images/captchas/";
$conf['avatar_path'] = "${_SERVER['DOCUMENT_ROOT']}/images/members/avatars/";
$conf['avatar_url'] = "http://${_SERVER['HTTP_HOST']}/images/members/avatars/";
$conf['photo_path'] = "${_SERVER['DOCUMENT_ROOT']}/images/members/photos/";
$conf['photo_url'] = "http://${_SERVER['HTTP_HOST']}/images/members/photos/";
One thing to remember is that ExpressionEngine requires 777 permissions on this file for installation, so the software can overwrite these settings if you update something in the control panel.
Personally I change my config file settings back so it’s not writable by the software and I handle any updates in the file itself but that can get confusing because if you try to update something in control panel and it fails, you don’t get any warning.
Email
Print
Post to Twitter
Post to Delicious
Add Your Comment?
You must have an EE Insider account to post comments on Insider Tips. It's fast, easy and hassle-free.
Sign up now (or login).