0

I have an app folder and a public folder. In the public folder is my .htaccess that look like this:

<IfModule mod_rewrite.c>
    Options -Multiviews
    RewriteEngine On
    RewriteBase /public
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule  ^(.+)$ index.php?url=$1 [QSA,L]
</IfModule>

The problem I have, is when I call the url on: http://localhost/public/images without a trailing slash and the images folder already exists. The results looks like this after I enter the address: http://localhost/public/images/?url=images.

But in the other hand, if I add a slash in the end like this: http://localhost/public/images/ it will remain like this when I enter. So specifically, it only works when I write a slash at the end.

This issue only occurs if there is a folder on that search address.
Someone who has a solution for this?

M. Sundstrom
  • 425
  • 1
  • 4
  • 13

1 Answers1

1

If you want to treat http://localhost/public/images as http://localhost/public/images/, you should enforce a trailing slash.

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)([^/])$        /$1$2/ [L,R=301]

See also: .htaccess Rewrite to Force Trailing Slash at the end

Ben
  • 4,856
  • 4
  • 17
  • 26