I have WordPress at address http://www.example.com/blog/, now I want it to be accessible as http://www.example.com/ without moving wordpress to root directory.

I have made appropriate .htaccess changes.


define("WP_HOME", "http://{$_SERVER["HTTP_HOST"]}");
define('WP_CONTENT_DIR', $_SERVER["DOCUMENT_ROOT"] . "/blog/wp-content");
define('WP_CONTENT_URL', "http://{$_SERVER["HTTP_HOST"]}/blog/wp-content");

One thing that doesn't work is WordPress uses www.example.com/wp-includes/ instead of www.example.com/blog/wp-includes/

There are even includes like www.example.com/%post-name%/wp-includes/js/jquery/jquery.js?ver=1.7.2

I have fixed it through .htaccess:

RewriteRule wp-includes/(.*) /blog/wp-includes/$1 [L]

Is threre a better way?


1 Answer 1


Add to wp-config.php:

define('WP_SITEURL', 'http://example.com/blog/');

On the codex.
This is all you need.

  • I want WP_SITEURL to be example.com That is where the problem comes from.
    – Stancell
    Sep 27, 2012 at 8:32
  • Read the documentation WP_SITEURL will only point to the folder where the WP files are. WP_HOMEURL points to the website in the browser.
    – janw
    Sep 27, 2012 at 8:39
  • Thanks, you pointed my error. I used site_url() in many places and that is the reason it didn't work for me.
    – Stancell
    Sep 28, 2012 at 8:30
  • Full solution - codex.wordpress.org/Giving_WordPress_Its_Own_Directory
    – Stancell
    Sep 28, 2012 at 10:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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