How to add more than one file name to extensionless rule

I already have extensionless urls working for .html files, however I found out the site used to also have .php and .aspx files. I was told elsewhere to use the following (first two lines) but it throws an internal server error. I just noticed I may need to edit the very last line (line 6). If so, can someone tell me how to write it?

thanks

RewriteCond %{THE_REQUEST} \.(html | php | aspx)
RewriteRule ^(.+)\.(html | php | aspx)$ http://example.com/$1 [R=301,L]

RewriteCond %{REQUEST_URI} !(\.[^./]+)$
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) /$1.html [L]

Hi @info2057 and welcome to the forum.

When testing try creating a test directory and creating a .htaccess file and some test .HTML, .aspx, .php, etc files so that the tests will not affect the main site.

Try also prefixing any .htaccess lines with # to temporarily remove errors.

I think spaces are critical and not allowed when using | php | aspx |

Also required is the RewriteEngine On Apache2 command

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.