I would like to run a wordpress site through a subdirectory but keep the actual domain.
Here is what I am trying to do.
Let's say, I have a site www.xyz.com
I have a wordpress instance installed on the root directory. However, i want to install a new wordpress instance in a subdirectory. I want to point the root worpdress instance to the subdirectory and keep the domain name without referencing to the subdirectory.
The subdirectory can be called let's say " test ". In the test directory, I will install a new wordpress instance.
Now, I want to point www.xyz.com to the "test" directory and still have the link as www.xyz.com. All the links should be www.xyz.com/post-name-sample and not www.xyz.com/test/post-name-sample.
Is there a mod-rewrite rule I need to setup within the .htaccess file?
Any help is appreciate. Thank you!
Try adding this to the .htaccess file
.htaccess main domain to subfolder redirect
# Copy and paste the following code into the .htaccess file
# in the public_html folder of your hosting account
# make the changes to the file according to the instructions.
# Do not change this line.
RewriteEngine on
# Change yourdomain.co.uk to be your main domain.
RewriteCond %{HTTP_HOST} ^(www.)?yourmaindomain.co.uk$
# Change ‘subfolder’ to be the folder you will use for your main domain.
RewriteCond %{REQUEST_URI} !^/subfolder/
# Don’t change this line.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Change ‘subfolder’ to be the folder you will use for your main domain.
RewriteRule ^(.*)$ /subfolder/$1
# Change yourdomain.co.uk to be your main domain again.
# Change ‘subfolder’ to be the folder you will use for your main domain
# followed by / then the main file for your site, index.php, index.html, etc.
RewriteCond %{HTTP_HOST} ^(www.)?yourmaindomain.co.uk$
RewriteRule ^(/)?$ subfolder/index.php [L]
It is possible to do with on wordpress: here is how to do it if you have it installed in a subdirectory already.
require( dirname( __FILE__ ) . '/wp-blog-header.php' );
to the following, using your directory name for the WordPress core files: require( dirname( __FILE__ ) . '/wordpress/wp-blog-header.php' );
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.