Forum Moderators: phranque
I already use the code below and it works fine.
The code works as follows: If a user asks for example.htm he will get example.tml if it exits. If the example.tml file does not exits we look after the same filename but with the .htm extension and the user will get that file.
What I need is a small piece of code that will tell the user, that if he asks directly for example.tml he will be told that the file does not exits.
Code:
RewriteRule ^(.*)\.htm$ $1 [C,E=OkHTM:yes]
RewriteCond %{REQUEST_FILENAME}.tml -f
RewriteRule ^(.*)$ $1.tml [S=1]
RewriteCond %{ENV:OkHTM} ^yes$
RewriteRule ^(.*)$ $1.htm
Sorry, the code doesn't work as intended.
When the code is executed, it works fine when I ask for a .tml file - the errorpage is shown. But when I ask for a .htm page that exsists as a .tml page I also get the errorpage - proberly because the code is executed one time more (the .tml file is requested and travels the way down the code - and already gets a hit at line one...)
All the .tml files have been moved to the folder /tml and the code works like this: When a .htm page is requested and not found (no matter the filepath), the page is requested as a .tml file in the folder /tml and shown with the first requested path/adress.
RewriteCond %{REQUEST_FILENAME}.htm !-f
RewriteRule ([^/]+.)htm$ /tml/$1tml [L]