In most cases, it is not illegal to directly connect a river to the ocean, as this can occur naturally through the river's natural flow and drainage patterns. However, any human-made modifications or diversions of rivers that could significantly impact the environment or disrupt natural water systems would typically be subject to various environmental regulations and permitting requirements.