This file is located at the root directory, along with index.php. It is worth mentioning that .htaccess is parsed and executed by the web server and not by zoglair. It provides directory-level configuration, as opposed to the server-wide one. It can contain most of the commands (or directives) found in the server's main configuration file (httpd.conf), although it is commonly used for URL rewriting, thanks to the mod_rewrite module.

Depending on your OS, .htaccess may be hidden, due to its name starting with a dot. If you do not see this file, make sure that you have setup your file manager or FTP client to show hidden files.

The .htaccess included in zoglair package contains a few rewriting rules, all of them optional except the last one:

  • The first two of them handle your default subdomain (www) and are mutually exclusive: you must select either or none, never both. If you setup zoglair with multi-domain support, those rules should be in your web server's virtual hosting configuration file (usually, vhost.conf), instead.
  • The next one handles serving of static content, such as images, scripts and styles. You can choose between zoglair (the default) and your web server.
  • Next comes a utility rule you can use, when closing your server down for maintenance.
  • The last one is absolutely essential and required: without this, zoglair simply cannot work.

Keeping in mind that a hash symbol (#) marks a line as a comment, here is an explanation of the included directives...

To www or not to www?

To rephrase the above question, is “www.example.com” better than “example.com”? If you google for an answer, you will get a lot of opinions and arguments in favor of either of them! And that is because there are serious pros and cons for both. One thing, however, is for sure: you should decide which one serves your site better and stick to it. There is no mistake in having “www” as your default subdomain, neither to not having it. But serving content from both IS a mistake, as it can have a great impact on your search engine ranking.

The “www vs non-www” issue is handled by redirecting URLs from one to another, and that is the purpose of the first two rules in zoglair's .htaccess. Chose one of them and remove the leading hashes (#) so that they are effective. The reason of why they are commented out - in the first place - is because they should only be active on a live public server. For obvious reasons, they cannot be used when zoglair is run under localhost.

Serving static content

A web page, usually, is a mixture of dynamic and static content. Dynamic content is the one which is pulled from a database and/or generated on the fly. Static content is the one which is pulled from the filesystem, such as images, scripts and styles.

The web server knows how to serve a request for a static content: it just reads the file pointed to by the url and sends it back to the user agent. It cannot do that for dynamic content, and that is the reason of why we are using a CMS in the first place!

Zoglair, however, not only knows how to send both content types, but it is specially crafted to deal with static content in the most efficient way. This is, in fact, one of its features, as most other CMSs are not tuned up for this task.

So, a question arises: which one should be used for serving static content - zoglair or the web server? The former gives you flexibility and access control. The latter gives you a slightly better performance. In any case, this question is best answered by your server administrator (or web host).

Zoglair relies on apache_request_headers() to look for and parse the “If-Modified-Since” header for deciding whether a particular request is a cache-hit or not. If that function is not available, zoglair has no other choice than to serve the request, no matter what.

(C) Nick B. Cassos - All Rights Reserved
powered by zoglair
page generated in 254ms (11 queries, 18ms)