How to match an optionally part of URL

I got a website to show different languages to user.

mywebsite.com/urlrule1

mywebsite.com/urlrule2

mywebsite.com/urlrule

mywebsite.com/urlrulen

those urls will be shown to user with their preferred/selected language.

But meanwhile I’d like to have the following urls:

fr.mywebsite.com/urlrule1

fr.mywebsite.com/urlrule2

fr.mywebsite.com/urlrule

fr.mywebsite.com/urlrulen

These urls will be with french regardless the users current language selection.

Or:

mywebsite.com/fr/urlrule1

mywebsite.com/fr/urlrule2

mywebsite.com/fr/urlrule

mywebsite.com/fr/urlrulen

But actually they are same.

Just too many repeated rules in the config.

Any simple, native solution to this problem?

Thanks.