You have to follow various steps:
- Close the board & backup everything.
- Move all the files from /public_html to /public_html/sub_directory
- Change the values in 'setting' table:
- Change the board URL in the database to '(your_domain)/sub_directory' by adjusting the 'bburl' value.
- Change the Cookie path to '/sub_directory' or '/' by adjusting the 'cookiepath' value. Safest and easiest value is '/', except when you're using some kind of SSO integration with your site in the same domain.
- Clear all browser cookie, cache and login into AdminCP of new site address.
- Change Attachment file paths in case you use File System to store attachment (AdminCP -> Attachments -> Attachment Storage Type).
In case you use Database to store attachments, this step is not needed.
- Change Avatar/Profile Picture/Signature file path (AdminCP -> Avatars -> Attachment Storage Type).
- Clear system cache (AdminCP -> Maintenance -> Clear System Cache).
- Redirect all URL from old domain to new subdirectory (using .htaccess for example).
- Open the board.