Sunday, 30 January, 2005
Web server configuration headaches
I just spent a maddening few hours trying to get search engine friendly (SEF) URLs working for the Mambo installation on my test server. SEF tells Mambo to generate more "natural" looking URLs for the pages. That is, instead of something like http://charlie/index.php?option=com_content&task=blogsection&id=4&Itemid=49, the URL becomes http://charlie/content/blogsection/4/49/. This is very important if you want search engines to index your site, as many search engines will discard a URL that looks as if it's pointing to dynamic content. This shouldn't be terribly difficult to change, right? Just enable Mambo's SEF option and set the proper options in the .htaccess file to enable Apache's rewrite engine.
The first problem I ran into was enabling .htaccess files on my system. The documentation says to locate the <Directory /> section in the /etc/apache2/httpd.conf file, and add a line that says "AllowOverride All". That's easy enough even for a Linux novice like me. I restarted Apache and ... it didn't work. The Web server continued to ignore my .htaccess directories. Honestly, I wasn't terribly surprised by this, as just about everything I try to do under Linux involves reading the documentation to see how somebody thought it was supposed to work, and then scouring the Internet to determine what really works.
After looking at more documents than I care to remember, I came to the conclusion that Apache really is supposed to work that way. So, figuring that something in my configuration was overriding my AllowOverride setting, I went searching. I found the culprit in the file /etc/apache2/default-server.conf, which httpd.conf includes after the <Directory /> section. The directives in default-server.conf "apply to all virtual hosts, unless deleted or overridden somewhere else." I had to change the "AllowOverride None" directive in default-server.conf in order to make my .htaccess files work. I don't know if this arrangement of configuration files is part of the standard Apache 2.0 distribution, or if it's specific to SuSE 9.2. Either way, it's pretty darned confusing.
I got SEF working on the test server, but am having trouble getting it to work on the production hosting server. My .htaccess file appears to be working, but apparently Sectorlink has disabled the Apache option that allows URL rewriting. That's understandable, considering the security implications of URL rewriting if you configure it incorrectly. If I can't get Sectorlink to enable the option, I'll have to come up with another way to process search engine friendly URLs.