Just a quickie:
I wanted to put this wordpress-driven blog in a subdirectory of the site (i.e., www.mattvsworld.com/blog), but I wanted the root of the site (www.mattvsworld.com) to be the same as the root of the blog (www.mattvsworld.com/blog). Here’s how I did it (using apache and mod_rewrite):
- Created the subdirectory “blog” on the web server, and placed the normal wordpress installation entirely within that fodler.
- Ran the installation normally (if you already installed in the root and moved, you can just modify the configuration files to indicate that it’s new location)
- Copied the “index.php” file from the “blog” directory to the site root.
- Modified the now-root index.php, changing the line:
require('./wp-blog-header.php');
to
require('./blog/wp-blog-header.php');
- Since I wanted the wordpress-managed robots.txt file to be available from the normal site root directory (i.e. /robots.txt rather than /blog/robots.txt), I created an .htaccess file in the site root with the following contents:
<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^robots.txt$ /blog/robots.txt </IfModule>
And now I’m happy — the site root is managed with wordpress, but the blog is nicely nested within a /blog/ subdirectory. In case I need to change things in the future, my permalinks should stay, well, perma!
Cheers
{ 1 comment… read it below or add one }
Thanks, Matt. I was wondering how to redirect robots.txt and your little piece of code does the trick.
Cheers,
Rose