Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am having a tough time removing the subfolders from the URL in my WordPress site.

Currently, the URL format is: www.mysite.com/subfolder/index.php/category/postname

I would like to remove both the subfolder AND index.php from the URL.

The site must stay in a subfolder of root on my server.

My current htaccess file is:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /subfolder/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /subfolder/index.php [L]

I've tried to add the following, although it did not work.

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^subfolder/(.*)$ http://www.mysite.com/$1 [R=301,L]
RewriteRule .* index.php/$0 [PT,L] 
share|improve this question

1 Answer 1

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:

// 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]

# 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:

add_filter( 'got_rewrite', '__return_true' );
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.