Im having an issue with my joomla site. At first it would create duplicates of urls with and without trailing slash. So I implemented some htaccess code to force a trailing slash. Then it was causing soft 404s that is, if I entered a non existent page the status in my crawler was actually 200 for these non existing pages, but it was just a 404 page template. Not a hard 404. So I changed that in the "error.php" file.
However the issue is that when I enter any non-existent url like "domain.com/nonexistentpage" (without a trailing slash) it first redirects it via the 301 rule to the "domain.com/nonexistentpage/" and THEN returns a 404.
If I stop the redirecting of pages, than that same URL "domain.com/nonexistentpage" will return a hard 404 as expected, but the URLs wont redirect to the trailing slash version (which I need). However if I redirect it, it will 301 before 404ing.
I dont have any pages on my site that are not without a trailing slash, so I want all pages that dont exist to go straight to my "error.php" file and be excepted from the 301 rule. How would I do this? Here is my coded attempt
RewriteCond %{REQUEST_URI} !-d
RewriteCond %{REQUEST_URI} !-f
RewriteRule .? - [S=1]
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ http://www.domainxyz.com/$1/
RewriteRule .+ - [L]
Im very inexperienced with htaccess. the idea was that if the file is non existent that the slash rewrite rule should be ignored.
RewriteCondlike that... - CD001