aoline.com simple non technical information

TYPO3 mod_rewrite & Simulate static urls

TYPO3 allows wonderfully simple static urls that can be used as they are, eg page.html or actually published static pages into the root folder so that the actual static pages work seamlessly alongside the dynamic pages that simply look like static pages.

However, I still get stumped with them not working out-of-the-box on new servers so this is my checklist to get things working.

1) Is mod_rewrite enabled?

Check your phpinfo() to see if the mod_rewrite is listed in the loaded modules section.

If it is not then on Debian I run the following command as root

a2enmod rewrite

Followed by a reload of the http conf as follows.

/etc/init.d/apache2 reload

Re-check your phpinfo() output and you should now see mod_rewrite loaded.

2) Are you allowed to override httpdconf?

If your mod_rewrite is still causing problems you probably need to check if you are allowed to override the conf. On debian the config is located in your /etc/apache2/apache2.conf file. Check the section for the virtual host/site you need the mod_rewrite and check if AllowOverride is set to None or All. Just change it to All and save/exit and reload the httpconf again.

3) Garbaged output on screen?

Oops I had this because I attempted to use zlib compression in my .htaccess file over the top of the Apache compression!

4) Over to TYPO3 setup template.

Add this code:

############################################
# 1 - STATIC SIMULATE
#RewriteRule .* /sub_folder/index.php
############################################
config.simulateStaticDocuments = 1
#config.absRefPrefix = www.yourwebdomain.com
config.simulateStaticDocuments_noTypeIfNoTitle = 1

5) Back into your .htaccess file

Add this code near the end:

RewriteEngine On
RewriteRule ^(typo3|typo3temp|typo3conf|t3lib|tslib|fileadmin|uploads|showpic\.php)/ - [L]
RewriteRule ^typo3$ typo3/index_re.php [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
# this next line if in root folder
RewriteRule .* index.php [L]
# OR this next line if in sub folder
#RewriteRule .* /sub_folder/index.php

6) All set up

Clear your TYPO3 cache and browse your front end files. If you get urls like:

43.html

Then you need to edit the page header of each page and set to advanced type and add the alias of the page. This will replace the number page uid with the alias to generate urls like:

alias.html