[TYPO3-core] RFC #5020: Use better rewrite rules in .htaccess
Ernesto Baschny [cron IT]
ernst at cron-it.de
Mon Jun 21 08:45:09 CEST 2010
Hi Michiel,
Michiel Roos [netcreators] schrieb am 19.06.2010 10:30:
> This is an SVN patch request.
>
> Type: Cleanup
>
> Bugtracker references:
> http://bugs.typo3.org/view.php?id=5020
>
> Branches:
> - trunk
>
> Problem:
> The rewrite rules are more complicated than they need to be. This will
> affect the loading speed of any site (citation and measurements needed).
>
> Solution:
>
> Rule 1:
> - Never rewrite 'static' resources. That would be silly right? If a
> certain request exists as an actual file on the filesystem: serve the file.
>
> Rule 2
> - Rewrite everything else.
>
> Rule 3
> - wrap the rewrite stuff with an <ifModule > to avoid 500 errors.
The main benefit I see with the rule:
RewriteRule
^(typo3|t3lib|tslib|fileadmin|typo3conf|typo3temp|uploads|showpic\.php|favicon\.ico)/
- [L]
is that it includes the whole directory structure, saying: "There is no
frontend rendering in these directories".
I have seen plenty of extensions, modules and site implementations where
the biggest performance hit was reference to non-existing files in
typo3conf/... (e.g. a CSS file) which ended up trying to render an not
existing path as a frontend page (going through realurl, TYPO3 frontend
rendering etc), which was much worse than just a "404" from the web
server which would have been served in no time.
So -1 on the change from my side.
Cheers,
Ernesto
> -------------------------------------------------------------------------------------------
> <IfModule mod_rewrite.c>
> RewriteEngine On
>
> # Do not rewrite static resources
> RewriteCond %{REQUEST_FILENAME} -f [OR]
> RewriteCond %{REQUEST_FILENAME} -d [OR]
> RewriteCond %{REQUEST_FILENAME} -l
> RewriteRule .* - [L]
>
> # Rewrite the rest to index.php
> RewriteRule .* /index.php [L]
> </IfModule>
> -
> -------------------------------------------------------------------------------------------
>
> Ship with this .htaccess enabled by default since it is safe and sane.
>
> A more elaborate (but old, I use Nginx now) article is here:
> http://www.typofree.org/article/archive/2008/june/title/rethinking-the-realurl-mod-rewrite-rules/
>
> I'm still very interested in load graphs, more speed measurements for
> big sites if you can produce any.
>
> Thanks
>
More information about the TYPO3-team-core
mailing list