Hi Jim,
Thank you for your reply.
The 'only' URL's that need to have a slash at the end of the URL are the individual article pages.
I'll try to explain:
It's a Joomla website located in the folder /blog/
In this Joomla site, there are 7 sections.
Depending on the sections there are several categories.
All categories have 1 or more article(s) (some have a few hundred articles).
The blog folder obviously has a slash at the end of the URL (it's a folder).
The section URL's have a slash as well.
So do the category URL's.
This leaves me with just the "articles" that need a slash.
- They are all "clean" URL's, because we use a SEF extention, except for the "search" option, but those URL's aren't indexed and taking into account that the redirect has a condition that the URL should start with blog/ and should have 4 "levels", this won't cause a problem in our new setup.
- There are no physical existing files within the section or categories.
- There are no strings in any of the URL's (except for the search url's, but those aren't 4 "levels" deep).
Taking the above and your reply into account, I came up with this, which seems to work.
# Externally redirect to add a trailing slash if no filetype
# or trailing slash is present on the requested URL-path
# If the URL starts with "blog/"
# If the URL contains four "levels": blog(1)/somthing1(2)/something2(3)/the-article(4)
RewriteCond %{REQUEST_URI} ^/blog/(.*)$
RewriteCond $1 !^([^/]+/)*[^/.]+$
RewriteRule ^/*(.+/)?([^.]*[^/])$ [
%{HTTP_HOST}...] [L,R=301]
However it works to "well", it puts a slash to any URL that doesn't have one. It lacks the check to see if the URL that needs to get rewritten is actually a 4th "level" URL. I'm at a loss on how to create a RewriteCond for this. Could you point me in the right direction?
With kind regards,
George