Redirect My Entire Domain URL Call Subfolder to Root Directory

0
193

If my website using WordPress CMS Programming and installed in a subfolder already.Now I want to configure and it up to display on the root domain using simple htaccess file .

Example that Basically, mydomain.com displays the contents of mydomain.com/subdirectory( changable path).

I need to redirect that entire subfolder (folder and all contents) back to the root – e.g. point mydomain.com/subdirectory to mydomain.com.

My Questions Like Bellow-

1) WordPress installation in a folder in the root, like in /subdirectory
2) Wp admin is accessible via http://www.mydomain.com/subdirectory/wp-admin/
3) Site opens in root folder like: http://www.mydomain.com/

Just Follow Few Simple Steps:

Step #1:

To change permalinks, there should creates or needs a .htaccess file

Step #2:

Copy /subdirectory/index.php to /index.php, so to the root directory of your site hosting

Edit the index.php like it –

/** Loads the WordPress Environment and Template */
require( dirname( __FILE__ ) . ‘/subdirectory/wp-blog-header.php’ );

Step #3:

Edit /.htaccess and keep it root directory

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /subdirectory/
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /subdirectory/index.php [L]
</IfModule>
# END WordPress

Step #4:

WordPress settings:

Go to the wordpress admin, and find out settings > general

edit the following two fields

WordPress Address: http://www.mydomain.com/subdirectory
Site address: http://www.mydomain.com/