You need to make the WP site url and home url differ in Settings / General. The home url should be example.com
, while the site url (where WP lives) should be example.com/wp
(or wherever you put it).
You can hardcode these in your config file:
define('WP_HOME', 'http://example.com');
define('WP_SITEURL', 'http://example.com/wp');
WP should know how to take things from there, and place the .htaccess where it should be.
In case it doesn’t, my own site’s folder looks like this:
- .htaccess
- index.php
- wp
The index.php file contains:
<?php
// WordPress view bootstrapper
define( 'WP_USE_THEMES', true );
require( './wp/wp-blog-header.php' );
And the .htaccess contains:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Regarding the /index.php
bit in URLs generated by WP, it means WP is (incorrectly?) finding that your site cannot manage permalinks. (Can I wager that this is because you’re using Nginx?)
Assuming you know better than WP, add a must-use plugin in your wp-content/mu-plugins folder, e.g. a force-permalinks.php file:
<?php
add_filter( 'got_rewrite', '__return_true' );