I use the configuration below in .htaccess
file to force trailing slash at the end of the url.
But this setting is not good when an url is wrong (city parameter is not present in the database) because it redirect /wrongcity
to /wrongcity/
instead to send a 404 error.
How can I solve this problem?
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)([^/])$ /$1$2/ [L,R=301]
RewriteRule ^([A-Za-z0-9-]+)//?$ index.php?city=$1 [L]