Weird redirect behaviour in Apache

Hi guys,

Something, somewhere, adds a trailing slash in one of my route. Don’t know why.

I’m serving Ember from an Apache server and uses this rewrite rule to send all request to index.html

<IfModule mod_rewrite.c>
    RewriteEngine On
    #RewriteBase /
    RewriteRule ^index\.html$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.html [L]
 </IfModule>

Everything seems fine until i have to replace the index page temporarily with a static page at /campaign.

// routes/index.js
export default Ember.Route.extend({
  ...

  beforeModel() {
    this.replaceWith('campaign');
  }

  ...
});

The homepage is correctly redirected to /campaign.

But when I refresh, this issue happens. Something adds a trailing slash at the end of the URL, and turns it into /campaign/. Which breaks the app.

There’s nothing in the /routes/campaign.js. And this only happen to this page. The other works just fine.

Okay. i found the problem. very stupid of me, turns out it’s because i have a folder of images with the same name.

This what confuses Apache. I have both a route /campaign and a folder /campaign/.

Case closed.