This forum has been moved here:
Helicon Tech Community Forum

Helicon Ape (Forum Locked Forum Locked)
 Helicon Tech : Helicon Ape
Subject Topic: Difference to ISAPI_rewrite? Zend
Message |

Joined: 29 January 2011
Location: Germany
Posts: 3
Posted: 29 January 2011 at 1:06pm

On my development machine I use the licensed version of ISAPI_rewrite and have the following .htaccess content for a website:


RewriteEngine On
RepeatLimit 200

#  Defend your computer from some worm attacks
RewriteRule ^.*(?:global.asa|default\.ida|root\.exe|\.\.).*$ . [NC,F,O]

#Fix missing trailing slash char on folders
RewriteRule ^([^.?]+[^.?/])$ $1/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_URI} \.(js|ico|gif|jpg|jpeg|png|css)$
RewriteRule ^.*$ - [NC,L]

RewriteRule ^.*$ /index.php [NC,L]

Nothing special so far.
I use the same file on the staging server where I've installed the free version of Ape.
In PHP scripts I've $_SERVER['HTTP_X_REWRITE_URL']  == '/' when using ISAPI_rewrite and a uri like http://my.test.domain/search/. Zend Framework contains some code to handle HTTP_X_REWRITE_URL.
But Ape produces: HTTP_X_REWRITE_URL and also REQUEST_URI being set to /index.php/. That results in URLs http://my.test.domain/index.php/search/ spawn out by ZF's Http-Request class. And because it's fundamental, it's going through a lot of other ZF components, that are also influenced by that.

Why this different behaviour? Seems also not to be fully compatible with Apache's mod_rewrite.
Am I missing something?

Btw, I fixed the problem for all situations (in my environment) by he following PHP snippet in the index.php of Zend Framework MVC applications:

if (isset($_SERVER['HTTP_X_REWRITE_URL'])) {
    $requestUri = $_SERVER['HTTP_X_REWRITE_URL'];
} else {
    $requestUri = $_SERVER['REQUEST_URI'];

$requestUri = preg_replace('%^/index\.php%i', '', $requestUri);
if (isset($_SERVER['HTTP_X_REWRITE_URL'])) {
    $_SERVER['HTTP_X_REWRITE_URL'] = $requestUri;
$_SERVER['REQUEST_URI'] = $requestUri;

Back to Top Visit Schlimmer's Homepage
Admin Group

Joined: 15 August 2002
Posts: 6520
Posted: 30 January 2011 at 3:48am

Do you have ISAPI_Rewrite (any version) installed on the same machine with Ape? It may trigger double rewriting and chnaging of REQUEST_URI variable. These two products should never be installed on one server at a time.

Yaroslav Govorunov,
Helicon Tech
Back to Top Visit Yaroslav's Homepage

Joined: 29 January 2011
Location: Germany
Posts: 3
Posted: 30 January 2011 at 5:56am

No, two different machines. The one with ISAPI_rewrite is my development machine (Windows 7), the other with Ape on it is a staging server (Windows Server 2008 R, fresh install)
Back to Top Visit Schlimmer's Homepage
Admin Group

Joined: 30 January 2007
Location: Ukraine
Posts: 10519
Posted: 31 January 2011 at 9:48am

Ok, first, please try commenting out the section of PHP code you quoted above - Ape is capable of setting the REQUEST_URI variable by itself.
If it doesn't help, please make sure you don't have several instances of Ape registered on your server (probably different builds or manually
registered instances).
If it's all ok, please right-click the root in Ape Manager and select Zip and Save Ape configuration and send us the archive OR provide us
with remote access to your server (the quickest option).

Back to Top

Joined: 29 January 2011
Location: Germany
Posts: 3
Posted: 31 January 2011 at 6:30pm

I found the circumstance that's causing the behaviour, .htaccess is unaltered:

Now I just tested with this simple PHP-script:

echo $_SERVER['REQUEST_URI'] . '<br />';
echo $_SERVER['HTTP_X_REWRITE_URL'] . '<br />';

The output is:

So REQUEST_URI and HTTP_X_REWRITE_URL are set to different values (!) And that's what's causing the mess with Zend Framework: They first look for HTTP_X_REWRITE_URL.
But besides that: It's a bug imho.
Please try it yourself.
To be sure I uninstalled Helicon Ape Free (had Version 0058) and installed the actual 0059. No difference.
Be assured: There's only one version of Helicon Ape registered on the machine. It is a fresh Windows Server 2008 R2 install that also never had ISAPI_rewrite on it.

Btw. besides this little actual trouble: I really admire Helicon Ape. Excellent product!
Back to Top Visit Schlimmer's Homepage

Sorry, you can NOT post a reply.
This forum has been locked by a forum administrator.

Printable version Printable version