WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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

Not sure what exactly you want. Can you please elaborate your question a bit more?

If you want URLs like www.mysite.com/subfolder/postname (where the subfolder is where your WordPress install is), then just go to Settings > Permalinks and change it to Post Name.


If your WordPress install is in subfolder and you want URLs like www.mysite.com/category/postname, then set both the WordPress Address and Site Address to www.mysite.com and in Permalinks, choose Custom Structure and use this tag /%category%/%postname%.

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.