htaccess - How to regex in filesmatch to ALLOW a file name that ends in 5 or 6 digits.htm

In my htaccess, I only allow specific filenames to be accessed, until now. I need to match a filename like this:

some-364-file-name-12345.htm

or

some-364-file-name-123456.htm

    crude attempt of dozens 
        <FilesMatch "^[a-Z0-9]\d{5}/.htm$">  
## but need yada-yada-5 OR 6 digits followed by .htm

        Order allow,deny

        allow from all

        </FilesMatch>

My existing is this:

<FilesMatch "(index.html|robots.txt|sitemap.xml|subscribe.htm)$">

Order allow,deny

allow from all

</FilesMatch>

CAN I ACTUALLY add the solution to my existing line?

So, being very unfamiliar with regex, although I have been trying all day and can't figure this out, how can I allow the pages I have:

some-file-name-312-33-12345.htm

some-33-333-file-name-654321.htm

I just want to match all alpha numeric (also dashes) followed by a 5 or 6 digit number .htm

I need a guru as 6 hours of reading and attempting has brought me here.

Thanks...

Upvotes: 1

Views: 1263

Answers (1)

anubhava
anubhava

Reputation: 786289

Try this regex:

<FilesMatch "\d{5,6}\.html?$">

Upvotes: 1

Related Questions