Home > Tech > Wordpress Canonical Names

Wordpress Canonical Names

January 16th, 2008

So the problem is you have wordpress installed and you want to respond to multiple domain names, but you don’t have a complete list of domain names which the user may use. In other words you wnat wordpress to work with *.domainname.tld. If you do nothing you will get an error like the following.

Warning: main(/etc/wordpress/config-hostname.domainname.tld.php) [function.main]: failed to open stream: No such file or directory in /etc/wordpress/wp-config.php on line 6

Fatal error: main() [function.require]: Failed opening required '/etc/wordpress/config-hostname.domainname.tld.php' (include_path='.:/usr/share/php:/usr/local/share/php/php-openid-1.2.3/') in /etc/wordpress/wp-config.php on line

One way to get this working is to edit wp-config.php which should be in the root of you wordpress directory. There is a line:

require_once('/etc/wordpress/config-'.strtolower($_SERVER['HTTP_HOST']).’.php’);

Which loads a config file based on the url the clients entered which is fine if you’ve been absolutely consistent in using or not using a hostname when talking about your domain (and no one as added or removed one over the years without asking). Assuming that isn’t true you would like to accept www.doaminname.tld, domainname.tld, actualhostname.domainname.tld, etc. You can create a bunch of symbolic links, or if you only have one website on ther server you can simply change the above line to:

require_once('/etc/wordpress/config-www.domainname.tld.php');

That should use the same config file regardless of what url the user used.

Tech