I have a site I need to move to a subdirectory, and my old nemesis, htaccess, is giving me some problems.
First, I’m already using an htaccess file with the existing site. It’s doing a couple of things:
- redirects all “mydomain” requests to https to use a recently installed security certificate
- rewrites pretty urls to a single index page like:
mydomain.com/staff goes to mydomain.com/index.php?var1=staff
mydomain.com/about-us goes to mydomain.com/index.php?var1=about-us …
So, my current htaccess file looks like (and work great):
DirectoryIndex index.php
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} ^mydomain.com [NC]
RewriteRule ^(.*)$ http://www.mydomain.com/$1 [L,R=301,NC]
RewriteRule ^([^/.]+)/?$ index.php?var1=$1 [QSA,L]
So, I need to move the entire site transparently to a subfolder _NewDomainFolder
I’ve been able to sorta get it to work with varying degrees of success … it will redirect to index.php in the subfolder, but my url variables won’t work ( like: mydomain.com/staff or mydomain.com/calendar ).
I’ve got a feeling part of my problem is dealing with TWO htaccess files? One in the root folder that redirects to _NewDomainFolder, and then the htaccess file in the _NewDomainFolder folder that handles the url variables.
So, probably in the ROOT folder, a different htaccess file to rewrite to the sub folder, and in the subfolder, the htaccess above to keep everything else working correctly, yes? … and at a point in the near future, there will be two more domain names pointing at their own subfolders inside the same root as well. Don’t know if that makes a difference as far as future planning goes.
What/where do I need to tweak?
Thanks,
Les