Regex help for .htaccess

I want to exclude access to certain files using .htaccess files but i need help generating the correct regexp.

I want to exclude access to these two files:

soft1-pp_1.12-123456789010_amd64.deb
soft1-tt_1.12-123456789010_amd64.deb

Version numbers are changing (1.12-123456789010) and I want the FilesMatch to work even after the versions change. What’s the correct RegExp for it?

My .htaccess will be as following:

<FilesMatch "^(filename1|filename2)\.deb$">
        Order allow,deny
        Deny from all
        Allow from 127.0.0.1
</FilesMatch>

Answer

Try this regexp:

^soft1-(pp|tt)_[.0-9-]*_amd64\.deb$

Attribution
Source : Link , Question Author : user178250 , Answer Author : Pascal Schmiel

Leave a Comment