Support » Plugins » Having your weblog outside the WordPress directory

  • I installed the latest CVS today, wanting to get some work done on my site. I’ve installed WordPress in a /wordpress directory, to keep the root clean. Putting the index.php file in / works perfectly well, but you can’t point the site url to this location, because the admin part will fall apart (well, sort of).
    Anyway, to get to the point, using a little hack you can keep both things working:
    <pre>if(!preg_match(“/.*wordpress\/wp-admin.*/”, $_SERVER[‘REQUEST_URI’])){
    $siteurl = preg_replace(“/(.*)\/wordpress(.*)/”, “$1$2”, $siteurl);
    This will remove the /wordpress part of the site url, when you are not in the admin directory. If you are, the site url remains intact. In my code, replace wordpress by the directory in which you installed it.
    This hack must be placed in wp-includes/wp-db.php on line 44 (right after $siteurl = preg_replace(‘|/+$|’, ”, $siteurl);
    By the way, it would be a nice feature to specify a installation URI and a weblog URI (what this hack takes care of now).

Viewing 9 replies - 1 through 9 (of 9 total)
  • thanks! 🙂

    Seems like you’d want to put the comments page (and any other pages that the public would be viewing, like your rss feeds etc) outside that wordpress directory … but that’s just me.

    I don’t have any file hacks, and have my blog in a seperate directory than the index file. Everything works fine. All you have to do is change the includes. Then again, the includes have been changed for 1.0, so I don’t know if that changes anything or not.

    Jaykul: I’ll be using mod_rewrite anyway, so there is no real reason for me to move these files. If you are pointing to them directly, however, it is a good idea.
    Anonymous: If you change the include, you also hack the files.

    Nope. Not hacking any files. Just a template modification. Although I would like some clear instructions on how to do this in the documentation. Maybe I’ll head on over to wiki and try to write some up myself. I could probably figure it out if I did some research.

    Can a developer please comment on this? I think a lot of us would REALLY like this feature in WP. I cannot get my archives or comments to work with 1.0. I am not willing to do a lot of hacking either, to get this to work. Just build in a feature that would let us specify a directory for the installation, and a directory for the index file. PLEASE!

    Joshua – My opinion: I’m sure it will happen at some point, but there are other features that are higher priority than re-writing something that already works for the sake of moving files around.

    Thanks for the reply. Hopefully it will happen soon.

    With the new version of wordpress, where do you place the code in wp-includes/wp-db.php, there is no (right after $siteurl = preg_replace(‘|/+$|’, ”, $siteurl); on line 44 expect </div>”);. Any help would be welcomed.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Having your weblog outside the WordPress directory’ is closed to new replies.