Apache rewrite rule only working with full domain name

I’m trying to serve googlebot a static version of my JS app.

I’m using the following .htaccess file:

RewriteEngine On

RewriteCond %{QUERY_STRING} ^_escaped_fragment_=/(.*)$
RewriteRule ^$ /%1.html [L]

But its just serving index.html. If I change it to this:

RewriteEngine On

RewriteCond %{QUERY_STRING} ^_escaped_fragment_=/(.*)$
RewriteRule ^$ http://example.com/%1.html [L]

I get the following in my address bar:

http://example.com/somplace.html?_escaped_fragment_=/someplace

But I don’t want to reload the page, I just want to serve the html file.

I’ve asked my hosting company, but they say its not their problem.

I’m running Ubuntu 13.10 on a Rackspace Cloud server.

Has anyone else run into this issue?

My semi-helpful answer is that this code looks right, and when I ran it, it behaved as expected. So there must be something else going on that we can’t see here from your snippet of code. Are there other rewrite rules? Other htaccess files?

Hi Jeff, thanks for your reply.

There are no other rules in the script. That’s the whole thing.

There’s another .htaccess file in a subdirectory, but its irrelevant. Here it is just in case:

RewriteEngine on
RewriteRule ^uploads/(.*)$ ?filename=$1 [L]

There are no .htaccess files in any parent folders.

The server’s running Ubuntu 13.10, there’s a conf file in /etc/apache2/apache2.conf, but I can’t see anything in there.

These are the vhost settings:

<VirtualHost *:80>
    ServerName example.com
    DocumentRoot /var/www/example

    <Directory /var/www/example>
        Options Indexes FollowSymLinks Includes
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>