Posts tagged ‘Apache’

Russian and Chinese editing with Concrete 5

concrete multi language

It is not enough to add a Character set to your Template // or store it in UTF-8 without BOM (so the headers attached by PHP won’t break).

If TinyMCE only displays gibberish instead of the Russian / Chinese / … text you entered in edit mode, you should edit your .htaccess (located in the root directory of your site) and add the following:

AddDefaultCharset UTF-8

Optionally, while you’re at it, you can enable caching for your site:

#Speed UP!
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault “access plus 10 years”
ExpiresByType text/html “access plus 30 seconds”
</IfModule>

Seiten beschleunigen

Bereits beim Entwickeln der Seite ist es angenehmer, wenn der Server schneller reagiert.

Diese Yahoo! Seite hat mehr Informationen über Seitenbeschleunigung.

Interessante Tools werden ebenfalls angeboten:

  • YSlow – ein Firefox Plugin was ermittelt WARUM die Seite langsam ist
  • Smush.it™ – verkleinert Bilder verlustfrei!

Um möglichst viele Elemente in dem BrowserCache vorzuhalten, sollte man die Expires Headers richtig setzen.

Dieser Artikel gibt eine kurze Anleitung für Apache & mod_rewrite.

Ich benutze z.B. folgendes in meiner .htaccess:

#Speed UP!
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault “access plus 10 years”
ExpiresByType text/html “access plus 30 seconds”
</IfModule>

Natürlich muss man dazu sicherstellen dass mod_expires installiert ist. Unter Debian:

ls -l /etc/apache2/mods-enabled/

Unter Debian hat man auch bequeme Tools um Module zu aktivieren und zu deaktivieren (einfach aufrufen, sie bieten die entsprechenden Module an):

a2enmod – Modul aktivieren
a2dismod – Modul deaktivieren

Weitere Optimierungsmöglichkeiten bestehen im Einsatz von Kompression – mod_deflate, Reduktion der eingebundenen Dateien (ganz wichtig!) und natürlich dem Einsatz eines CDNs – eines Content Delivery Networks. Wir empfehlen MaxCDN (das erste Terabyte für 10$!) bzw. NetDNA.

Ein netter Nebeneffekt der meisten dieser Optimierungen ist die Reduktion der Last auf den Server – was wiederum zu höherer Performance bei vielen Besuchen führt!!

Auf Wunsch optimieren wir Ihre Seite hinsichtlich der beschriebenen Prinzipien um die optimale Geschwindigkeit für Sie und Ihre Besucher herauszuholen. Nehmen Sie mit uns jetzt Kontakt auf!

mod_rewrite and Concrete5

I was trying to additionally rewrite an URL before letting the classical Concrete5 mod_rewrite happen – everything matched to index.php, like so:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

Íf you try to paste any additional RewriteRule before this catch-all rule, your Apache will run into an endless loop, probably giving up with a 500 error. Your log will show something like:

access.log

(…) “GET” “114.ideaday.de” “/stellenmarkt/stellenangebote/” “redirect:/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/stellenmarkt/stellenangebote/”
error.log

[Sun Jan 24 16:57:52 2010] [error] [client 85.181.108.54] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use ‘LimitInternalRecursion’ to increase the limit if necessary. Use ‘LogLevel debug’ to get a backtrace.

Apparently mod_rewrite fails to recognize index.php as already being rewritten and keeps looping through the rule over and over again. Recent versions of Apache will stop after 10 iterations and yield a 500 error.
After nearly giving up, I’ve figured out a solution how to do this:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteRule ^stellenmarkt/stellengesuche/(.*)-([0-9]+)[/]*$ stellenmarkt/stellengesuche/gdemo/?id=$2 [L,QSA]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

As you see, the additional rule is placed before the Rewrite Conditions! This works, no more endless loops :-)