If you have changed your permalink structure to post name but still index.php is visible on URL then add the below code in the htaccess file which is located in the root directory of your WordPress files.