Created
November 20, 2013 20:36
-
-
Save kraftb/7570544 to your computer and use it in GitHub Desktop.
TYPO3 apache htaccess supporting realurl and nc_staticfilecache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
###################################################################### | |
# Copyright notice | |
# | |
# (c) 2013 webconsulting business services gmbh (office@webconsulting.at) | |
# All rights reserved | |
# | |
# Based on work of various TYPO3 authors. | |
# | |
# This script is part of the TYPO3 project. The TYPO3 project is | |
# free software; you can redistribute it and/or modify | |
# it under the terms of the GNU General Public License as published by | |
# the Free Software Foundation; either version 2 of the License, or | |
# (at your option) any later version. | |
# | |
# The GNU General Public License can be found at | |
# http://www.gnu.org/copyleft/gpl.html. | |
# A copy is found in the textfile GPL.txt and important notices to the license | |
# from the author is found in LICENSE.txt distributed with these scripts. | |
# | |
# This script is distributed in the hope that it will be useful, | |
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
# GNU General Public License for more details. | |
# | |
# This copyright notice MUST APPEAR in all copies of the script! | |
###################################################################### | |
############### | |
# | |
# rewrite-staticfilecache.conf | |
# | |
# This configuration should get included from apache instead of .htaccess configuration | |
# [1] http://httpd.apache.org/docs/2.2/howto/htaccess.html#when | |
# | |
# This configuration is for sites with realurl AND nc_staticfilecache. There are (should) | |
# be other variants for sites which use only realurl but NOT nc_staticfilecache. | |
# | |
# This file should get included from within apache config using a configuration like those | |
# below. They disable overriding using .htacces which should speed up the whole thing [1]. | |
# ------------------------- | |
# # httpdocs is the webroot | |
# <Directory /var/www/vhosts/yourserver.com/httpdocs> | |
# AllowOverride None | |
# Include /var/www/vhosts/yourserver.com/rewrite-staticfilecache.conf | |
# </Directory> | |
# ------------------------- | |
# | |
# If you use the feature of dynamic generation of .htaccess files by nc_staticfilecache | |
# you have to reenable them for the nc_staticfilecache cache directory. Do this by additional | |
# lines like those: | |
# ------------------------- | |
# <Directory /var/www/vhosts/yourserver.com/httpdocs/typo3temp/tx_ncstaticfilecache/www.yourserver.com> | |
# AllowOverride Indexes | |
# </Directory> | |
# ------------------------- | |
############### | |
##### | |
# | |
# Example .htaccess file for TYPO3 CMS - for use with Apache Webserver | |
# | |
# This file includes settings for the following configuration options: | |
# | |
# - Compression via TYPO3 | |
# - Settings for mod_rewrite (URL-Rewriting) | |
# - PHP optimisation | |
# - Miscellaneous | |
# | |
# If you want to use it, you have to copy it to the root folder of your TYPO3 installation (if its | |
# not there already) and rename it to '.htaccess'. To make .htaccess files work, you might need to | |
# adjust the 'AllowOverride' directive in your Apache configuration file. | |
# | |
# IMPORTANT: You may need to change this file depending on your TYPO3 installation! | |
# | |
# Lines starting with a # are treated as comment and ignored by the web server. | |
# | |
# You should change every occurance of TYPO3root/ to the location where you have your website in. | |
# For example: | |
# If you have your website located at http://mysite.com/ | |
# then your TYPO3root/ is just empty (remove 'TYPO3root/') | |
# If you have your website located at http://mysite.com/some/path/ | |
# then your TYPO3root/ is some/path/ (search and replace) | |
# | |
# You can also use this configuration in your httpd.conf, but then you have to modify some lines, | |
# see the comments (search for 'httpd.conf') | |
# | |
# Questions about this file go to the matching Install mailing list, see | |
# http://typo3.org/documentation/mailing-lists/ | |
# | |
#### | |
### Begin: Compression via TYPO3 ### | |
# Compressing resource files will save bandwidth and so improve loading speed especially for users | |
# with slower internet connections. TYPO3 can compress the .js and .css files for you. | |
# 1) Uncomment the following lines and | |
# 2) Set $TYPO3_CONF_VARS['BE']['compressionLevel'] = '9' | |
<FilesMatch "\.js\.gzip$"> | |
AddType "text/javascript" .gzip | |
</FilesMatch> | |
<FilesMatch "\.css\.gzip$"> | |
AddType "text/css" .gzip | |
</FilesMatch> | |
AddEncoding gzip .gzip | |
AddEncoding gzip .gz | |
# Set proper content type and encoding for gzipped html. | |
<Files *.html.gz> | |
ForceType text/html | |
<IfModule mod_headers.c> | |
Header set Content-Encoding gzip | |
</IfModule> | |
</Files> | |
### End: Compression via TYPO3 ### | |
### Begin: Browser caching of ressource files ### | |
# Enable long browser caching for JavaScript and CSS files. | |
# This affects Frontend and Backend and increases performance. | |
# You can also add other file extensions (like gif, png, jpg), if you want them to be longer cached, too. | |
### End: Browser caching of ressource files ### | |
### Begin: Settings for mod_rewrite ### | |
# You need rewriting, if you use a URL-Rewriting extension (RealURL, CoolUri, SimulateStatic). | |
<IfModule mod_rewrite.c> | |
# Enable URL rewriting | |
RewriteEngine On | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteCond %{REQUEST_FILENAME} !-d | |
RewriteRule ^(.+)\.(\d+)\.(php|js|css|png|jpg|gif|gzip)$ $1.$3 [L] | |
# Stop rewrite processing, if we are in the typo3/ directory. | |
# For httpd.conf, use this line instead of the next one: | |
# RewriteRule ^/TYPO3root/(typo3/|t3lib/|fileadmin/|typo3conf/|typo3temp/|uploads/|favicon\.ico) - [L] | |
RewriteRule ^(typo3/|fileadmin/|typo3conf/|typo3temp/|uploads/|favicon\.ico) - [L] | |
# Redirect http://example.com/typo3 to http://example.com/typo3/index_re.php and stop the rewrite processing. | |
# For httpd.conf, use this line instead of the next one: | |
# RewriteRule ^/TYPO3root/typo3$ /TYPO3root/typo3/index.php [L] | |
RewriteRule ^typo3$ typo3/index_re.php [L] | |
######### nc_staticfilecaceh begin ----------------------------------------------------- | |
RewriteCond %{REQUEST_URI} !^/$ | |
RewriteCond %{REQUEST_FILENAME} -f [OR] | |
RewriteCond %{REQUEST_FILENAME} -d [OR] | |
RewriteCond %{REQUEST_FILENAME} -l | |
RewriteRule .* - [L] | |
#------------------------------------------------------------------------------ | |
# beginning of static file cache rulesets | |
# Set gzip extension into an environment variable if the visitors browser can handle gzipped content. | |
RewriteCond %{HTTP:Accept-Encoding} gzip [NC] | |
RewriteRule .* - [E=TX_NCSTATICFILECACHE_GZIP:.gz] | |
# Append missing slashes | |
RewriteRule ^(.*[^/])$ $1/ | |
# Don't cache HTTPS traffic. You may choose to comment out this | |
# option if your site runs fully on https. If your site runs mixed, you will | |
# not want https traffic to be cached in the same typo3temp folder where it can | |
# be requested over http. | |
# Enable this if you use a mixed setup. | |
#RewriteCond %{HTTPS} off | |
# We only redirect URI's without query strings | |
RewriteCond %{QUERY_STRING} ^$ | |
# NO frontend user is logged in. Logged in frontend users may see different | |
# information than anonymous users. But the anonymous version is cached. So | |
# don't show the anonymous version to logged in frontend users. | |
RewriteCond %{HTTP_COOKIE} !nc_staticfilecache [NC] | |
# We only redirect GET requests | |
RewriteCond %{REQUEST_METHOD} GET | |
# NO backend user is logged in. Please note that the be_typo_user cookie expires at the | |
# end of the browser session. If you have logged out of the TYPO3 backend and are expecting to see cached pages but don't. Please close this browser settion first or remove the cookie manually or use another browser to hit your frontend. | |
RewriteCond %{HTTP_COOKIE} !be_typo_user [NC] | |
# Check for Ctrl Shift reload | |
RewriteCond %{HTTP:Pragma} !no-cache | |
RewriteCond %{HTTP:Cache-Control} !no-cache | |
# It only makes sense to do the other checks if a static file actually exists. | |
#RewriteCond %{DOCUMENT_ROOT}typo3temp/tx_ncstaticfilecache/%{HTTP_HOST}%{REQUEST_URI}index.html%{ENV:TX_NCSTATICFILECACHE_GZIP} -f | |
# Uncomment the following line if you use MnoGoSearch | |
#RewriteCond %{HTTP:X-TYPO3-mnogosearch} ^$ | |
RewriteCond %{DOCUMENT_ROOT}/typo3temp/tx_ncstaticfilecache/%{HTTP_HOST}%{REQUEST_URI}index.html%{ENV:TX_NCSTATICFILECACHE_GZIP} -f | |
# Rewrite the request to the static file. | |
# Rewrite to the target | |
RewriteRule ^(.*)$ typo3temp/tx_ncstaticfilecache/%{HTTP_HOST}/$1index.html%{ENV:TX_NCSTATICFILECACHE_GZIP} [L] | |
# end of static file cache ruleset | |
#------------------------------------------------------------------------------ | |
######### nc_staticfilecaceh end ------------------------------------------------------- | |
# If the file/symlink/directory does not exist => Redirect to index.php. | |
# For httpd.conf, you need to prefix each '%{REQUEST_FILENAME}' with '%{DOCUMENT_ROOT}'. | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteCond %{REQUEST_FILENAME} !-d | |
RewriteCond %{REQUEST_FILENAME} !-l | |
# Main URL rewriting. | |
# For httpd.conf, use this line instead of the next one: | |
# RewriteRule .* /TYPO3root/index.php [L] | |
RewriteRule .* index.php [L] | |
</IfModule> | |
### End: Settings for mod_rewrite ### | |
### Begin: PHP optimisation ### | |
# If you do not change the following settings, the default values will be used. | |
# TYPO3 works fine with register_globals turned off. | |
# This is highly recommended, if your web server has it turned on. | |
#php_flag register_globals off | |
### End: PHP optimisation ### | |
### Begin: Miscellaneous ### | |
# Make sure that directory listings are disabled. | |
#Options -Indexes | |
### End: Miscellaneous ### | |
# Add your own rules here. | |
# ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
I have used the above code inside my Typo3/ folder inside the .htaccess file. But except the allowoverride i did everthing,When i do that apache is not running ... Please help me on this.