[REQ] static pages in a different location (higher) than blog home (2 posts)

  1. matthewc
    Posted 11 years ago #

    i'm almost certain this can't currently be done without hacking, so i'm reposting it here as a feature request.

    the static page feature is great, it means i can use wordpress in the slightly more 'cms'-ish way i want to. however, here's what i'd like to do...

    http://example.com = static front page (non-wordpress)
    http://example.com/blog = blog home
    http://example.com/page1 = 'static' page (wordpress controlled)

    it should be possible to expand the static pages so that they can be hierarchically above the blog uri... it would just mean creating the necessary mod-rewrite rules in a separate .htaccess in the higher directory, rewriting to the actual blog uri

    actually taking this further, there is no reason why the front page of the site couldn't be a wordpress-controlled 'static' page. now that *would* be cool.

    i'm pretty sure i can get this working by hacking the .htaccess filew... i'll post an example if i manage it.

  2. wersh
    Posted 11 years ago #

    I wanted to do the same thing and fought for a while before I could get it to work, but it seems to be working okay now. Here's how I do it:

    Install wordpress in /wp.

    Create a static page in your root with a slug named "home" (or similar) that you want to be the index to your root.

    Go to Options in the admin panel, then to Permalinks, and make sure that both the permalink and the archive items start with /blog/ (or whatever section of your site you want your blog stuff to go in).

    Go to Options in the admin panel, then to General and change Blog Address from http://example.com/wp to http://example.com

    On your webserver, go to the root directory for your site and in your .htaccess, put the following:

    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^.*$ - [S=2]
    RewriteRule ^blog/?$ /wp/index.php [QSA,L]
    RewriteRule ^(.*)$ /wp/$1 [QSA]
    RewriteRule ^$ /wp/home [QSA]

    If the request is for a file that really exists, the above does nothing. If it is requesting exactly /blog/ it will show your base blog page (recent posts). If it is any other non-blank request, it will redirect to the /wp directory, where the rewrite rules there will take care of it. If it is a blank request (ie, they just went to the domain without a page request), it redirects them to the static page "home" you created.

    I *think* that's everything I did. If it doesn't work let me know and I'll try to figure out what else I might have done.

    Important note: If wordpress is installed in /blog/ and you try to have rewrite rules going to things that start with /blog/ then it won't work because those files actually exist and the bit at the beginning of the rewrite rules will skip it.

    Good luck!

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.