How to exclude Installed wordpress subdirectory from main domain?

I installed a wordpress to a subdirectory from a subdomain, It looks like this

I was able install it manually and I can access wp-admin, I can see also the homepage but when I try to click on my posts and categories they are all 404. I tried also modifying the htaccess on main subdomain to exclude the subdirectory and create an htaccess to the subdirectory because the wordpress installed doesn’t create even I tried to reset permalinks. I even chmod to 775 all the files inside the subdirectory and still nothing happens.

Please help thanks…