Forums / Cotonti / Core Labs / Ideas / Enhanced .htaccess

Proposed default .htaccess file for Cotonti

GHengeveld
#1 2010-11-30 08:04
Recently I've been looking into the HTML5 Boilerplate framework. This is a collection of front-end development best practices, css resets, javascript enhancements and a lot of other cool stuff aimed at speeding up your website. The framework also comes with a .htaccess file with tweaks for Apache servers.

I've worked a bit on this file to make it suitable for Cotonti. I've added some of my own tweaks that I often use with Cotonti too. I suggest we include this in Cotonti by default.

http://www.cotonti.com/datas/users/htaccess_68.txt

Features:
  • Add support for modern filetypes
  • Force PHP 5
  • Set file compression on web fonts
  • Configure cache expiration and disable ETags
  • Force Internet Explorer to use latest parsing engine, or Chrome frame if present
  • Disallow access to urltrans, cache and template files
  • Set ErrorDocuments to Cotonti messages
  • Automatically add www. to domain name for SEO *
  • Remove ending slash from URL for SEO *
* With support for HTTPS

Dit bericht is bewerkt door Koradhil (2010-11-30 08:41, 13 jaren ago)
urlkiller
#2 2010-11-30 14:46
wow O_o something new to look through...
URL shortener: <a href="http://bbm.li/!7AD5C7">http://bbm.li/!7AD5C7</a>
Kort
#3 2010-11-30 14:50
# Koradhil : Automatically add www. to domain name for SEO
This depends on the user choice and is done to stay away from duplicate links (same page with or without www). In most cases now www is removed to make the url shorter.
SED.by - создание сайтов, разработка плагинов и тем для Котонти
GHengeveld
#4 2010-11-30 19:31
# Kort : This depends on the user choice and is done to stay away from duplicate links (same page with or without www). In most cases now www is removed to make the url shorter.
Agreed, it's a personal preference. I also think without it looks better, but there's a reason for using www. If the site itself is under the www subdomain, all cookies will be stored for this subdomain only. For performance it's better to serve images and other static content from a (sub)domain that does not have any cookies assigned to it. Otherwise the cookies will be sent along with every request for an image, even though that data is completely useless. If your site isn't under a subdomain all cookies stored by it are stored for every subdomain in the site, including a subdomain for static content, or Cotonti installations under other subdomains. It limits your options and if you have multiple sites under the same domain it can also be a security risk. Big sites often use different domain names entirely to serve static content, mainly to avoid the parallel download limit (2 files) of web browsers.

Many users probably wont use this technique and have only one instance of Cotonti running, so they can just as well remove the www instead of add it. That's up to the end user. Actually I should write a guide on how to setup static content delivery over a subdomain.

More info:
Use Cookie-free Domains for Components
Split Components Across Domains

Added 2 days later:

After discussing this with Trustmaster I've made some changes to the file. Some features have been removed or are disabled by default.

http://www.cotonti.com/datas/users/htaccess2_68.txt

  • Forcing PHP 5 is now optional (only needed for PHP 4 servers)
  • Disabling ETags is optional (only for cluster/cloud based servers)
  • Adding or removing 'www' is now up to the admin to decide, both are present but disabled by default.
  • Removing of ending slash has been removed, it's not really needed and may interfere with further rewriting.

Dit bericht is bewerkt door Koradhil (2010-12-03 07:41, 13 jaren ago)
ez
#5 2010-12-03 16:48
I knew (and used) a lot off these features, but his is a great list.

There are some new things for me that i will use for sure.

THNX
==- I say: Keep it EZ -==
urlkiller
#6 2010-12-04 16:34
a little thing i encounterd while playing around with it.

when using sub folders of a current url you also have to change
the error document paths. if you dont add the complete path in front of /message.php? like
/myfolder1/myfolder2/message.php? because somehow it wont work either..
URL shortener: <a href="http://bbm.li/!7AD5C7">http://bbm.li/!7AD5C7</a>
GHengeveld
#7 2010-12-04 18:59
Can you please explain the problem in more detail? I don't see your problem.
If you want you can always make the errordocument an absolute url (http://yoursite.com/message...).
urlkiller
#8 2010-12-06 00:57
yeah sure.

the thing was i was using a test domain in some subfolders like: mydomain.com/folder/folder/index.php

the htaccess but want's to change to mydomain.com/message.php and not to mydomain.com/folder/folder/message.php

so i just wanted to mention that this paths has to be changed too.
you just wrote: # Modify the rewritebase to match your Cotonti root path:
and didnt gave any hint that the paths from error docs need to be changed too...
URL shortener: <a href="http://bbm.li/!7AD5C7">http://bbm.li/!7AD5C7</a>
GHengeveld
#9 2010-12-06 02:55
Removing the starting slash should fix that, but if you then use rewriterules to create virtual subdirectories (for categories for example), the errordocuments won't work correctly. Best solution is to either use an absolute url to the errordocument or use /folder/folder/message.php
The starting slash ensures the path is defined from the root of the domain rather than the current url path.