If someone visit /file.php or /file.asp or /file.htm or /file.jsp, they should be redirected to /file/
If the files exist, replace
- Code: Select all
# Remove the .php from PHP files (only files
# that exist).
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{DOCUMENT_ROOT}%{SCRIPT_FILENAME} -f
RewriteRule ^(/.+)\.php$ $1/ [R=301,L]
with
- Code: Select all
# Remove the .extension from PHP, ASP, HTML
# and JSP files (only files that exist).
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{DOCUMENT_ROOT}%{SCRIPT_FILENAME} -f
RewriteRule ^(/.+)\.(asp|html?|jsp|php)$ $1/ [R=301,L]
Or if they don't exist add
- Code: Select all
RewriteRule ^(/.+)\.(asp|html?|js)$ $1/ [R=301,L]
after
- Code: Select all
RewriteRule ^([^\?]*)index\.php(\?.*)?$ $1$2 [R=301,L]
/htmlfile to go to /htmlfile.html and /aspfile to go to /aspfile.asp, etc.
This can be done by the way.