I have a problem with my htaccess. I want to add a trailing slash to my URL. I'm currently developing locally. So here's the htaccess:
Options +FollowSymlinks
RewriteEngine On
#RewriteBase
RewriteBase /balade-gourmande
DirectoryIndex index.php
# Add ending slash
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ %{REQUEST_URI}/ [R=301,L]
# Main pages
RewriteRule ^(.*)/(.*)/$ $2.php [L]
RewriteRule ^(.*)/$ $1.php [L]
As you can see, I have a lot of other website on my localhost (Why I have a rewritebase). All my .php files are in the "balade-gourmande" directory.
I have a index.php and a yes.php file in the balade-gourmande folder.
If I try:
localhost/balade-gourmande/ -> It's ok, I land on index.php
localhost/balade-gourmande/yes -> It's ok, I land on yes.php
localhost/balade-gourmande/yes/ -> It's ok, I land on yes.php
The problem is if I enter something wrong, ex:
localhost/balade-gourmande/whatever
It give me a: localhost/balade-gourmande/whatever.php.php.php.php.php.php.php.php.php.php.php.php.php.php.php.php.php.php.php/
with infinite loop error...
Can someone help me with this, if you need more info, I'll try m y best.
Thx!
** Edit:
Here's the htaccess located in the root, not in my "balade-gourmande/":
Options +FollowSymlinks
RewriteEngine On
#RewriteBase
DirectoryIndex index.php
# Error
ErrorDocument 404 '/errorhandler.php'
# Add ending slash
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ %{REQUEST_URI}/ [R=301,L]
# Page principales
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1\.php -f [NC]
RewriteRule ^(.+?)/?$ /$1.php [L]