How To: Move Wordpress Pages into a subfolder
From ThinkLemon
[edit]
Notice
The below actions are only valid for the WordPress 2.0 range! Because of a significant change in how WordPress handles permalinks it will not work in WordPress 1.5.x The steps provided below will be lost if you upgrade to a future version.
The *hacks* below are a quick fix. Meaning it might not be the most optimal way to put 'pages' in a sub folder. It works for ThinkLemon. If you care to implement this on your own installation, please backup first and test that everything is still working!
For WordPress 1.5.x see the previous revision.
[edit]
Prerequisites
You need to have some understanding on PHP, Apache and MySQL (phpMyAdmin).
- Apache with Mod_rewrite enabled
- WordPress (2.0+)
- Permalink structure enabled (see Admin panel > Options > Permalinks)
[edit]
Steps
- Make sure you have the WordPress Permalink Structure in your htaccess file. Follow the instructions given by your installation.
- Add a record in the 'wp_options' table:
- Open up your Wordpress MySQL Database using phpMyAdmin or other,
go to the 'wp_options'-table,
add a new record with 'option_name': 'page_uri_base' and 'option_value': /pages. (The preceding slash is needed to find pages off the root)
- Patch 'template-functions-links.php' in the 'wp-includes'-folder:
- Find the function 'get_page_link($id = false)' and
alter the line (#97?) that says:$link = get_settings('home') . "/$link/";
into:$link = get_settings('page_uri_base') . "/$link/";
(Or comment the line out and add the new one below)
- Patch 'classes.php' in the 'wp-includes'-folder:
- Find 'class WP {' on line #1423),
after line #1463 ($home_path = $home_path['path'];) add:
// CUSTOM: Added for Pages!!!
$pages_path = parse_url(get_settings('page_uri_base'));
$pages_path = $pages_path['path'];
- after line #1472 (
$req_uri = str_replace($home_path, ' ', $req_uri);) add:
// CUSTOM: Added for Pages!!! $req_uri = str_replace($pages_path, '', $req_uri);
If all is well all the Wordpress Pages will now be available under /pages/...
