Index > Contao core > IIS ISAPI_Rewrite
I have installed TL on a windows Server 2003 machine with IIS6. TL works great if I have rewriteUrl set to false and with disableAlias set to true or false, but when I turn on rewriteUrl, I have a problem.
I installed ISAPI_Rewrite3 but for some reason, it has a problem with 'RewriteRule .*html index.php [L]'. I have tried several different rules in the .htaccess and they work, but when i set it to 'index.php', the browser cannot load the page and it looks like ISAPI_Rewrite gets stuck in some sort of loop.
I don't get any errors in the TL logs, or the ISAPI_rewrite error logs, however the rewrite logs show an infinite loop through this following process:
If I empty index.php then the above process doesn't loop and the browser loads index.php without any problems.
I have searched the forums, FAQ's and the ISAPI_rewrite site extensively but cannot find an answer. I'm probably missing something simple, which I hope you can hep me with?
Many thanks in advance.
I installed ISAPI_Rewrite3 but for some reason, it has a problem with 'RewriteRule .*html index.php [L]'. I have tried several different rules in the .htaccess and they work, but when i set it to 'index.php', the browser cannot load the page and it looks like ISAPI_Rewrite gets stuck in some sort of loop.
I don't get any errors in the TL logs, or the ISAPI_rewrite error logs, however the rewrite logs show an infinite loop through this following process:
Code:
init rewrite engine with requested uri /index.html Htaccess process request C:\Program Files\Helicon\iSAPI_Rewrite3\httpd.conf Htaccess process request C:\InetPub\website\.htacess applying pattern '.*html' to uri 'index.html' escaping /index.php Rewrite to URL to >> /index.php rewrite 'index.html' -> '/index.php' init rewrite engine with requested uri /index.php Htaccess process request C:\Program Files\Helicon\iSAPI_Rewrite3\httpd.conf Htaccess process request C:\InetPub\website\.htacess applying pattern '.*html' to uri 'index.php'
If I empty index.php then the above process doesn't loop and the browser loads index.php without any problems.
I have searched the forums, FAQ's and the ISAPI_rewrite site extensively but cannot find an answer. I'm probably missing something simple, which I hope you can hep me with?
Many thanks in advance.
2008-03-04 00:55
Ok, so I went ahead and tried IISRewrite but the same problem occurs. It could be something to do with the differences with Apache and IIS.
I could be way off but I think this is what's happening...
APACHE
1. The user navigates to 'index.php' and TYPOlight then redirects them to 'index.html'
2. Even though the user has been redirected to 'index.html', the htaccess tells apache to keep showing 'index.html' in the address bar but present the 'index.php' file to the user
3. The process stops here.
IIS
1. The user navigates to 'index.php' and TYPOlight then redirects them to 'index.html'
2. Even though the user has been redirected to 'index.html', the ISAPI_Rewrite tells IIS to keep showing 'index.html' in the address bar but present the 'index.php' file to the user
3. The IIS server thinks the user is navigating to 'index.php' again and TYPOlight redirects to 'index.html', which takes us back to stop 1 and starts the loop again.
Does that sound like it could be the problem? If so, I wonder if there is a fix without installing Apache on the Windows machine.
Any thoughts, opinions or ideas much appreciated.
Thanks
T
I could be way off but I think this is what's happening...
APACHE
1. The user navigates to 'index.php' and TYPOlight then redirects them to 'index.html'
2. Even though the user has been redirected to 'index.html', the htaccess tells apache to keep showing 'index.html' in the address bar but present the 'index.php' file to the user
3. The process stops here.
IIS
1. The user navigates to 'index.php' and TYPOlight then redirects them to 'index.html'
2. Even though the user has been redirected to 'index.html', the ISAPI_Rewrite tells IIS to keep showing 'index.html' in the address bar but present the 'index.php' file to the user
3. The IIS server thinks the user is navigating to 'index.php' again and TYPOlight redirects to 'index.html', which takes us back to stop 1 and starts the loop again.
Does that sound like it could be the problem? If so, I wonder if there is a fix without installing Apache on the Windows machine.
Any thoughts, opinions or ideas much appreciated.
Thanks
T
2008-03-06 22:50
It seems, unsurprisingly, that the answer to this one is a bit of a puzzle. My solution was to install Apache on the Windows machine in favour of IIS.
T
T
2008-03-12 18:11
Finally using Apache is surely not a bad solution, I would even prefer it over IIS on any windows server 
Anyway the problem with the IIS rewrite modules could be incompatibility, so the syntax in .htaccess might have to be modified.
Anyway the problem with the IIS rewrite modules could be incompatibility, so the syntax in .htaccess might have to be modified.
Peter - "May the the TYPOlight shine on you"
2008-03-13 01:12
Thierry,
I believe you are navigating uncharted territory, as I do not recall anyone else getting IIS rewrites working. So you never had any luck and switched to Apache to get things working?
I believe you are navigating uncharted territory, as I do not recall anyone else getting IIS rewrites working. So you never had any luck and switched to Apache to get things working?
2008-03-13 16:10
Hey Ben,
Yes, I switched to Apache and it works as expected. It's a shame really as it would be nice to know if it was indeed something to do with the TL redirect not working well with IIS. I guess if i knew this from the start I wouldn't have gone with IIS. I'll probably get back to testing it another day just to figure out what the problem was as i'm still not 100% sure. If I figure it out I'll let Leo know so he can list it on the requirements.
T
Yes, I switched to Apache and it works as expected. It's a shame really as it would be nice to know if it was indeed something to do with the TL redirect not working well with IIS. I guess if i knew this from the start I wouldn't have gone with IIS. I'll probably get back to testing it another day just to figure out what the problem was as i'm still not 100% sure. If I figure it out I'll let Leo know so he can list it on the requirements.
T
2008-03-13 18:35
Hi Thierry,
Have you tried with IIS + IIRF http://www.codeplex.com/IIRF/ ?
I'm using apache but I'm interested by a working IIS solution...
Have you tried with IIS + IIRF http://www.codeplex.com/IIRF/ ?
I'm using apache but I'm interested by a working IIS solution...
2008-03-13 19:09
hi guys!
i've managed it!
i tried IIRF on IIS6 and the url rewriting worked but it took me long to work out the ini file but it's just that simple:
as you can see, i use typolight in a subdir ("cms") but the rewriting should also work without the subdirs as far as you use ".html" as suffix
little hacks (of course) are the exclusion of
the typolight urls: to get the backend working
and the file directory: to get the downloads and images working
if anybody knows some improvements, please let me know
hope it is useful!
i've managed it!
i tried IIRF on IIS6 and the url rewriting worked but it took me long to work out the ini file but it's just that simple:
Code:
#UrlRewriting für TYPOlight RewriteRule ^/cms(?![typolight|tl_files|index|preview])(.*html)$ /cms/index.php/$1 [I,L]
as you can see, i use typolight in a subdir ("cms") but the rewriting should also work without the subdirs as far as you use ".html" as suffix
little hacks (of course) are the exclusion of
the typolight urls: to get the backend working
and the file directory: to get the downloads and images working
if anybody knows some improvements, please let me know
hope it is useful!
Last edited by scheri, 2008-08-18 01:23
2008-08-12 22:33
hi guys!
i've have several problems with my url rewriting config...
i've managed to get the basic functionality working (last post) but now i'm facing a few problems.
hope anybody could fix my rule or give me some hints to solve my problems
thank you
i've have several problems with my url rewriting config...
i've managed to get the basic functionality working (last post) but now i'm facing a few problems.
- the whole search enginge doesn't work with my rewrite rules
- forms do not work either (e.g. contact form)
- i think the rules i made are quite buggy because i am not really a rewriting expert
hope anybody could fix my rule or give me some hints to solve my problems
thank you
Last edited by scheri, 2008-11-14 10:28
2008-11-14 10:28
problem SOLVED!
the following version of the IIRF ini file works now for the current release and should be fine for all of you:
greets
scheri
the following version of the IIRF ini file works now for the current release and should be fine for all of you:
Code:
# IsapiRewrite4.ini # # TYPOlight Rewrite URL # by Christoph Scherübl # # 14.11.2008 # #RewriteLogLevel 5 RewriteRule (.*css)$ $1 [I,L] RewriteRule ^(?!index.php)(?!sitemap.xml)(?!tl_files)(?!/system)(?!plugins)(?!templates)(?!typolight)(.*)$ index.php$1 [I,L]
greets
scheri
Last edited by scheri, 2008-11-14 20:11
2008-11-14 19:27
Thanks scheri for sharing 
2008-11-21 19:23
Since none of the above ini file settings work, I tested with testdriver.exe and a test site after getting all urls to work.
I also checked against the .htaccess file which does less to rewrite the urls, but the equivalent for IIRF couldn't handle forms. I did not test with any module or extension, but since the test site is being tested before going live I guess those problems, if any, will be found and I'll solve them and post back here. Anyhow, here is the code:
ps, I didn't know anything about rewrite rule until 2 hours ago. If I made some mistake, be sure to kick my ass and all
ps2, The only thing I didn't get is why the syntax for IIRF isn't the same as for apache rewrite. Seems to me that if you want to clone functionality from one system to another you'd also make the syntax the same?? (and look for .htaccess files and parse the rules you recognize)
[Edit: Come to think of it, the following will work as well:
[Edit: ps3, If you run typolight in a subdir, then you probably need to add it in the ini file or someone needs to rewrite these rulse so they take possible subdirs into account.]
Note:
The first one doesn't because [] brackets seem to be for character classes and any path starting with a p for example wouldn't work because the p is a letter in the words "typolight|tl_files|index|preview". So not any of the characters "defghilnoprstvwxy|" at the start of a path is going to work. (/products.html, /notworking.html)
The second one is just inconsistent and I do not understand why it is the way it is. Perhaps it did work on an older version of IIRF??
I also checked against the .htaccess file which does less to rewrite the urls, but the equivalent for IIRF couldn't handle forms. I did not test with any module or extension, but since the test site is being tested before going live I guess those problems, if any, will be found and I'll solve them and post back here. Anyhow, here is the code:
Code:
# IsapiRewrite4.ini # # TYPOlight Rewrite URL # #RewriteLogLevel 5 RewriteRule (.*css)$ $1 [I,L] RewriteRule (.*xml)$ $1 [I,L] RewriteRule (.*js)$ $1 [I,L] RewriteRule ^/(?!index.php)(?!tl_files)(?!system)(?!plugins)(?!templates)(?!typolight)(.*)$ /index.php/$1 [I,L]
ps, I didn't know anything about rewrite rule until 2 hours ago. If I made some mistake, be sure to kick my ass and all
ps2, The only thing I didn't get is why the syntax for IIRF isn't the same as for apache rewrite. Seems to me that if you want to clone functionality from one system to another you'd also make the syntax the same?? (and look for .htaccess files and parse the rules you recognize)
[Edit: Come to think of it, the following will work as well:
It didn't give any errors on the test urls and worked on the test server]Code:
RewriteRule ^(/?index\.php.*)$ $1 [L] RewriteRule ^(/?)(.*\.html)$ $1index.php/$2 [L]
[Edit: ps3, If you run typolight in a subdir, then you probably need to add it in the ini file or someone needs to rewrite these rulse so they take possible subdirs into account.]
Last edited by Ruud, 2009-02-22 09:33
2009-02-21 23:37
Hi @ all,
I'm sorry to bring this topic up again after such a long time but does anybody have the current TypoLight Version 2.7.1 working with IIRF Version 1.2.15 (also latest version)? I can't get it working together. It always redirects me to the home page of my website so that nothing actually happens.
Any ideas?
Regards,
Eric
I'm sorry to bring this topic up again after such a long time but does anybody have the current TypoLight Version 2.7.1 working with IIRF Version 1.2.15 (also latest version)? I can't get it working together. It always redirects me to the home page of my website so that nothing actually happens.
Any ideas?
Regards,
Eric
2009-06-14 09:34
