Getting problem in removing end slash from directory

Posted by user2615947 on Pro Webmasters See other posts from Pro Webmasters or by user2615947
Published on 2013-08-16T18:03:08Z Indexed on 2013/10/17 16:26 UTC
Read the original article Hit count: 279

Filed under:

this is my code but i tried many ways but it is not working and i am not able to remove the end slash from the directory

RewriteEngine On
RewriteBase /

# remove enter code here.php; use THE_REQUEST to prevent infinite loops
RewriteCond %{THE_REQUEST} ^GET\ (.*)\.php\ HTTP
RewriteRule (.*)\.php$ $1 [R=301]

# remove index
RewriteRule (.*)/index$ $1/ [R=301]

# remove slash if not directory
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} /$
RewriteRule (.*)/ $1 [R=301]

# add .php to access file, but don't redirect
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteCond %{REQUEST_URI} !/$
RewriteRule (.*) $1\.php [L]

# Remove trailing slashes
RewriteRule ^(.*)\/(\?.*)?$ $1$2 [R=301,L]

Thanks

© Pro Webmasters or respective owner

Related posts about htaccess