Adding a trailing slash after adding www and removing .php

Viewed 280

I have a site with pages like about.php, contact.php and test.php?id=xyz.

I added the below redirect for making it seo friendly.

Options -Indexes -MultiViews

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.krishibazar\.org$ [NC]
RewriteRule ^(.*)$ http://www.krishibazar.org/$1 [R=301,L]

# To externally redirect /dir/file.php to /dir/file
RewriteCond %{THE_REQUEST} \s/+(?:index)?(.*?)\.php[\s?] [NC]
RewriteRule ^ /%1 [R=301,L,NE]

# To internally forward /dir/file to /dir/file.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1\.php -f [NC]
RewriteRule ^(.+?)/?$ /$1.php [L]

This gives me

mydomain.com                      =>  www.mydomain.com
mydomain.com/about.php            =>  www.mydomain.com/about
mydomain.com/test.php?id=12       =>  www.mydomain.com/test?id=12
mydomain.com/about/               =>  CSS Error

It is working perfectly fine except if i add a trailing slash at the last its giving error. So either suggest me to prevent the error or adding a trailing slash.

1 Answers
Related