Last active
July 1, 2019 11:37
-
-
Save john-clark/34eb70476ddadb0616b0 to your computer and use it in GitHub Desktop.
typo3 htaccess to web.config conversion - comments please
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
<?xml version="1.0" encoding="UTF-8"?> | |
<!-- | |
##### | |
# | |
# Example web.config file for TYPO3 CMS - for use with IIS webServer | |
# | |
# This file includes settings for the following configuration options: | |
# | |
# - Compression via TYPO3 | |
# - Settings for mod_rewrite (URL-Rewriting) | |
# - PHP optimisation | |
# - Miscellaneous | |
# | |
# This attempts to be a direct conversion from the .htaccess apache rules | |
WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING | |
This is a work in progress and may not work. Outside Input Solicited! | |
WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING | |
# | |
# 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 'web.config'. | |
GitHub Gist does not save tha language type so I added the .xml extension | |
# | |
# 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 occurrence 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) | |
# | |
# | |
# Be aware: Comments in xml are not made with # as in .htaccess | |
# Look for the settings between the arrows, and comment/uncomment as needed. | |
# | |
# WARNING: EDITING IIS SITE SETTINGS WITH THE GUI WILL CHANGE THIS FILE | |
# AND MAY REMOVE THE COMMENTS THAT CONTAIN VALUABLE SETTINGS | |
# | |
# Questions about this file go to the matching Install mailing list, see | |
# http://typo3.org/documentation/mailing-lists/ | |
# | |
#### | |
--> | |
<configuration> | |
<!-- Allow Rewrites --> | |
<configSections> | |
<sectionGroup name="system.webServer"> | |
<sectionGroup name="rewrite"> | |
<section name="rewriteMaps" overrideModeDefault="Allow" /> | |
<section name="rules" overrideModeDefault="Allow" /> | |
</sectionGroup> | |
</sectionGroup> | |
</configSections> | |
<system.webServer> | |
<!-- | |
### 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. | |
# *) Uncomment the following lines and | |
# *) Set $TYPO3_CONF_VARS['BE']['compressionLevel'] = '9' for the Backend | |
# *) Set $TYPO3_CONF_VARS['FE']['compressionLevel'] = '9' together with the TypoScript properties | |
# config.compressJs and config.compressCss for GZIP compression of Frontend JS and CSS files. | |
*** The .htaccess rules commented out by default so remove the arrows to uncomment | |
--> | |
<!-- | |
<httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files"> | |
<scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll"/> | |
<dynamicTypes> | |
<add mimeType="text/css" enabled="true"/> | |
<add mimeType="application/javascript" enabled="true"/> | |
</dynamicTypes> | |
<staticTypes> | |
<add mimeType="text/ccs" enabled="true"/> | |
<add mimeType="application/javascript" enabled="true"/> | |
</staticTypes> | |
</httpCompression> | |
<urlCompression doStaticCompression="true" doDynamicCompression="true"/> | |
--> | |
<!-- | |
If you have problems see | |
http://stackoverflow.com/questions/15499956/iis-7-5-static-content-compression-not-consistent | |
### 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. | |
--> | |
<caching> | |
<profiles> | |
<add extension=".js" policy="CacheForTimePeriod" kernelCachePolicy="CacheForTimePeriod" duration="7:00:00:00" /> | |
<add extension=".css" policy="CacheForTimePeriod" kernelCachePolicy="CacheForTimePeriod" duration="7:00:00:00" /> | |
</profiles> | |
</caching> | |
<!-- | |
### End: Browser caching of ressource files ### | |
### Begin: Settings for mod_rewrite ### | |
--> | |
<rewrite> | |
<rules> | |
<clear /> | |
<!-- | |
# Change this path, if your TYPO3 installation is located in a subdirectory of the website root. | |
#RewriteBase / | |
# Rules to set ApplicationContext based on hostname | |
#RewriteCond %{HTTP_HOST} ^dev\.example\.com$ | |
#RewriteRule .? - [E=TYPO3_CONTEXT:Development] | |
#RewriteCond %{HTTP_HOST} ^staging\.example\.com$ | |
#RewriteRule .? - [E=TYPO3_CONTEXT:Production/Staging] | |
#RewriteCond %{HTTP_HOST} ^www\.example\.com$ | |
#RewriteRule .? - [E=TYPO3_CONTEXT:Production] | |
***NOT SUPPORTED ON IIS or done different*** | |
# Rule for versioned static files, configured through: | |
# - $TYPO3_CONF_VARS['BE']['versionNumberInFilename'] | |
# - $TYPO3_CONF_VARS['FE']['versionNumberInFilename'] | |
# IMPORTANT: This rule has to be the very first RewriteCond in order to work! | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteCond %{REQUEST_FILENAME} !-d | |
RewriteRule ^(.+)\.(\d+)\.(php|js|css|png|jpg|gif|gzip)$ $1.$3 [L] | |
This is equivalent to the following iis rule | |
--> | |
<rule name="Static Files" stopProcessing="true"> | |
<match url="^(.+)\.(\d+)\.(php|js|css|png|jpg|gif|gzip)$" /> | |
<action type="Rewrite" url="{R:1}.{R:3}" /> | |
</rule> | |
<!-- | |
# Basic security checks | |
# - Restrict access to deleted files in Recycler directories | |
# - Restrict access to TypoScript files in default templates directories | |
# - Restrict access to Private extension directories | |
--> | |
<rule name="Block Recycling Bin"> | |
<match url="^fileadmin/(.*/)?_recycler_/" /> | |
<action type="Abort" /> | |
</rule> | |
<rule name="Block Template ts and txt"> | |
<match url="^fileadmin/templates/.*(\.txt|\.ts)$" /> | |
<action type="Abort" /> | |
</rule> | |
<rule name="Block Private Resources"> | |
<match url="^typo3conf/ext/[^/]+/Resources/Private/" /> | |
<action type="Abort" /> | |
</rule> | |
<!-- | |
# Stop rewrite processing, if we are in the typo3/ directory. | |
--> | |
<rule name="Don't redirect these" stopProcessing="true"> | |
<match url="^(typo3/|fileadmin/|typo3conf/|typo3temp/|uploads/|favicon\.ico)" /> | |
<action type="None" /> | |
</rule> | |
<!-- | |
# If the file/symlink/directory does not exist => Redirect to index.php. | |
# Main URL rewriting. | |
--> | |
<rule name="Rewrite Rule remaining Conditions" patternSyntax="Wildcard"> | |
<match url="*" /> | |
<conditions> | |
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> | |
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> | |
</conditions> | |
<action type="Rewrite" url="index.php" /> | |
</rule> | |
<!-- | |
### End: Settings for mod_rewrite ### | |
# Add your own rules here. | |
# ... | |
# Make IIS behave like apache | |
<rule name="Add trailing slash" stopProcessing="true"> | |
<match url="(.*[^/])$" /> | |
<conditions> | |
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> | |
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="false" /> | |
</conditions> | |
<action type="Redirect" redirectType="Permanent" url="{R:1}/" /> | |
</rule> | |
--> | |
</rules> | |
</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 | |
*** TURN THIS OFF IN PHP.INI and its commented out *** | |
*** Probably should be some other items in this section **** | |
### End: PHP optimisation ### | |
### Begin: Miscellaneous ### | |
# Make sure that directory listings are disabled. (this is commented out but its a good idea) | |
--> | |
<directoryBrowse enabled="false" /> | |
<!-- | |
# Just in case... (commented out for me) | |
<defaultDocument> | |
<files> | |
<clear /> | |
<add value="index.php" /> | |
<add value="index.html" /> | |
</files> | |
</defaultDocument> | |
--> | |
<!-- | |
# show errors (in order to see things on iis disable some security) | |
--> | |
<httpErrors errorMode="Detailed" existingResponse="PassThrough" /> | |
</system.webServer> | |
<system.web> | |
<customErrors mode="Off" /> | |
</system.web> | |
<!-- | |
### End: Miscellaneous ### | |
--> | |
</configuration> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment