S
S
SDSsds2021-09-03 12:35:59
Apache HTTP Server
SDSsds, 2021-09-03 12:35:59

HTACCESS how to try to issue a file with one extension, but if it is not there, then try with another one?

Good for all.
I have the following task:
Given: in the uploads folder there is a file 1.xml and 2.html Needed
: it is necessary that the url opens: /upload/1.xml and /upload/2.xml so that in the second case Apache would give 2 instead of 404 .html
A big request to help with the rules in the version of universal file names, that is, variables ...
I googled for a long time, I will continue to google, but if anyone can help I will be very grateful.
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2021-09-03
@SDSsds

In that upload folder create a .htaccess file

RewriteEngine On

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

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question