I found this solution to redirect urls from www.domain.com/example.php to www.domain.com/example successfully but I cannot do the same when are few subdirs present, like with: domain.com/dir1/di2/dir3/example.php to domain.com/dir1/di2/dir3/example
How should this rule be modded in order to make the previous redirection work?
RewriteRule (.*).php$ /$1 [R=301,L]
RewriteRule (.*).html$ /$1 [R=301,L]
This is my .htaccess
ErrorDocument 404 /misc/404.html
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
RewriteRule (.*).php$ /$1 [R=301,L]
RewriteRule (.*).html$ /$1 [R=301,L]
# Forces a trailing slash to be added
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
#RewriteRule (.*)$ /$1/ [R=301,L]
Thank you!
You need to add a:
right below
RewriteEngine on.You also may need to add a
/en/to the redirect rules and conditions:Needs to be: