Redirecting domain to folder with SSL
One of my accounts located at yourdomain.com is a Wordpress site which resides in folder "subfolder" which is in public_html.
I used this htaccess code located in public_html to successfully reach the site:
What I notice is: - access from https:// and result in a double redirect which is very slow - I suspect the slowness is caused by firing up Wordpress in some way I've searched around and have not found a htacess snippet which does the job efficiently. Any clues? Thanks! /ljj
# .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.com to be your main domain.
RewriteCond %{HTTP_HOST} ^(www.)?yourmaindomain.com$
# 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.com 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.com$
RewriteRule ^(/)?$ subfolder/index.php [L]
What I notice is: - access from https:// and result in a double redirect which is very slow - I suspect the slowness is caused by firing up Wordpress in some way I've searched around and have not found a htacess snippet which does the job efficiently. Any clues? Thanks! /ljj
-
Hello, You may want to consider updating the document root for the domain name to match the path to the subdirectory as opposed to using Mod_Rewrite for this purpose. We document how to do this at: AutoSSL & different DocumentRoot Note that without root access, your hosting provider may need to perform this action on your behalf. Otherwise, consider moving the WordPress installation over to the public_html directory: Moving WordPress " WordPress Codex Thank you. 0 -
Hello, You may want to consider updating the document root for the domain name to match the path to the subdirectory as opposed to using Mod_Rewrite for this purpose. We document how to do this at: AutoSSL & different DocumentRoot Note that without root access, your hosting provider may need to perform this action on your behalf. Otherwise, consider moving the WordPress installation over to the public_html directory: Moving WordPress " WordPress Codex Thank you.
Yep, moving the site up to public_html seems like the right move. It was a site we took over from someone else, should have fixed it then.0
Please sign in to leave a comment.
Comments
2 comments