Local laws do not typically apply to visitors in terms of tourism unless they are laws that relate to the safety of the community. There is a blurry line between a statute and a custom, while both can be followed by the police and could have drastic implications on a foreigner, and a law could be entirely disregarded.
Customs relating to visiting holy places and respectful clothing are more like rules in the sense that people would let you know about it and not let you join otherwise. Some rules do not apply directly to visitors, but they should be understood to long-term residents working or doing voluntary service on the island. The rules mentioned below are vital to follow during the Sri Lanka holidays.
Taking pictures of holy sites and government departments
During family tours in Sri Lanka as the country’s political and socio-economic majority are Buddhists. The customs of respectfully entering a Buddhist temple include entering without shoes, conservatively dressed, not pointing feet at Buddha figures, not getting too close to or touching the monks (particularly their heads), and indicating respect towards the worshippers. Visitors are supposed to comply with all these laws, but there is one custom/law that can bring you into serious trouble. Any Buddhist temples and all government departments do not allow photos of the premises to be taken.
The most touristic Buddhist temples, such as Gangaramaya in Colombo, of course, encourage photographs to be taken, but they must be respectful. For example, refrain from clicking duck face selfies with Buddha figures. It can get you into trouble and even get you arrested for taking insensitive images on Buddhist premises. For taking a picture trying to kiss a Buddha statue, one woman was deported. Photography in government agencies is strictly forbidden.
A few people have seen some serious criticism for revealing their Buddha tattoos while on the island in regard to reverence for Buddhist tradition. If you have a tattoo of Buddha and plan to fly to Sri Lanka, it's best to find a way to cover it up while you're here.
Carrying drugs are illegal
You can get into serious trouble by being caught with illegal drugs. In Sri Lanka, pretty much all drugs are illegal, including marijuana. Police raids on the roads at night often take place, inspecting and searching three-wheelers and vehicles. It is an incredibly dangerous idea to use drugs such as morphine, opium, and cocaine. The outcome could be life imprisonment in a Sri Lankan jail, based on the number of drugs found on a person and whether it can be proven that there was trafficking involved.
However, the statute dictates that death by hanging is the punishment for possessing illegal drugs. Since the seventies, this has not been imposed and a life term is typically granted instead. Be alert, spending time in jail in Sri Lanka is the last thing any foreigner will do.
Topless Sunbathing
Sri Lanka is not the kind of place for ladies who want to sunbathe topless. In Sri Lanka, nudity and indecent exposure is a serious crime and what you can get by going topless is trouble.
The religious freedom
Sri Lanka has a provision that requires the entire population to follow a religion of their own. Buddhism is the dominant faith, but there are plenty of Hindus, Muslims, and Christians. This is not the rule, but there are certain people who do not believe in religious freedom and prefer to build violent conditions, and the government is working very hard to enforce religious freedom and quench conflict between religious communities.
What importance does this bring for travelers? This means that when you come to Sri Lanka, no matter what your faith is, you will be welcome. With members of other faiths, please don't be imperialist or abusive about it. That would definitely get you into trouble as it disrespects the Statute on Religious Freedom directly.