: Getting problem in removing end slash from directory 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
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$ [R=301]
# remove index
RewriteRule (.*)/index$ / [R=301]
# remove slash if not directory
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} /$
RewriteRule (.*)/ [R=301]
# add .php to access file, but don't redirect
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteCond %{REQUEST_URI} !/$
RewriteRule (.*) .php [L]
# Remove trailing slashes
RewriteRule ^(.*)/(?.*)?$ [R=301,L]
Thanks
More posts by @Miguel251
1 Comments
Sorted by latest first Latest Oldest Best
This will happen because you are removing the tailing slash and then expecting it to be added for directories, I don't think this will work and the work around would be to remove everything referring to adding a slash and use mod_autoindex.html
That way you can have /directory/index.html that will be processed without the tailing slash so this would look like /directory and still list your files as directory view. Quick and easy work around while maintaining the same URL structor of the rest of the site.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.