htaccess file for TNG and WordPress in separate root folders

steven
Posts: 133
Joined: Sun Oct 01, 2017 3:08 pm

htaccess file for TNG and WordPress in separate root folders

Post by steven »

You can to install TNG and WordPress in separate folders in the root of you website. If you run TNG using the TNG templates, you should create a link in WordPress to call TNG using a text widget. If you want to use a WordPress page to call TNG, you can use htaccess to redirect permalinks.

These instructions will work if you install WordPress in a root sub-folder but want to launch from a root index file. The index file should have the following lines of code:

Code: Select all

/**
 * Tells WordPress to load the WordPress theme and output it.
 *
 * @var bool
 */
define('WP_USE_THEMES', true);

/** Loads the WordPress Environment and Template */
require( dirname( __FILE__ ) . '/wordpress/wp-blog-header.php' );
If you do not want to create the index.php file yourself, click the download link. If you use a different folder name for WordPress edit the file and change wordpress to your folder name.

index.zip


To load TNG from a WordPress page, create an htaccess file in the root of your website. The htaccess file needs two sections to function correctly. The first section allows the WordPress permalink to find TNG along with a rewrite rule for TNG index.php. The second section contains the WordPress permalink rewrite rules. You will need to modify the wordpress and TNG folder names if they are different in your installation. Use the following code in .htaccess to redirect the WordPress permalink to the TNG folder and load TNG:

Code: Select all

# BEGIN TNG Root Rules
<IfModule mod_rewrite.c>
	RewriteEngine On
	RewriteBase /
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteCond %{REQUEST_FILENAME} !-d
#Redirect rules for TNG folder in root
	Redirect /wordpress/tng /tng
	RewriteRule ^([^\.]+)$ $1.php [NC]
# END TNG Root Rules

# BEGIN WordPress
	RewriteRule ^index\.php$ - [L]
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteCond %{REQUEST_FILENAME} !-d
	RewriteRule . /index.php [L]
# END WordPress
</IfModule>
If you do not want to create the .htaccess file yourself, click the download link below. Extract the file directly to your server because Windows does not like files with no name but have the .htaccess extension. You will need to edit the .htaccess file to use your folder names in the first section.

htaccess.zip


If you downloaded the .htaccess file prior to 12-24-17 at 10:00 pm please download the newest version. The WordPress installation will create a .htaccess file inside the WordPress folder which you will not need to modify. Remember to use WordPress pretty permalinks or these rules will not work. Pretty permalinks are anything other than the first option which is "plain".

The remainder of the TNG installation will be the same as that shown in Installing TNG in WordPress. Note when using this configuration, WordPress will be unable to modify the root htaccess file. If you need to make changes to the root htaccess file, you must make them manually.
You do not have the required permissions to view the files attached to this post.
Last edited by steven on Sun Apr 08, 2018 6:24 pm, edited 1 time in total.