This solution of Gumbo works great for files, yet it does not work with directories.
In other words:
For mysite.com/file1.php
, it shows mysite.com/file1/
which is great.
Yet, it does not work well for directories. If I try to access the following directory (that contains index.php file inside) mysite.com/dir1
, instead of showing the content of the http:/mysite.com/dir1/index.php
and the url: mysite.com/dir1/
, it returns 404.
My solution around it was:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{THE_REQUEST} ^GET\ /[^?\s]+\.php
RewriteRule (.*)\.php$ /$1/ [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*)/$ $1.php [L]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule .*[^/]$ $0/ [L,R=301]
In other words, not to do anything if its a directory.
Hope it helps.
Another problem with the original solution is that css and the images are not loaded until I change the path to the css file and to images to absolute path.
Is there any other way to solve it, rather then changing all the paths in all the files in the website to absolute.
Thanks a lot.