Little help with my nemesis, htaccess

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:

  1. redirects all “mydomain” requests to https to use a recently installed security certificate
  2. 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

I think I’ve got it, finally after scewing with it most of the afternoon and pulling out half my hair!

In my ROOT folder:

RewriteEngine On

RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

RewriteBase /

RewriteCond %{REQUEST_URI} !^/_site_ccjc/

RewriteCond %{HTTP_HOST} ^(www.)?columbiacityjazz.

RewriteRule ^(.*)$ /_site_ccjc/$1 [L]

Then inside the subfolder where the site now lives:

DirectoryIndex index.php

RewriteEngine On

RewriteCond %{HTTP_HOST} ^columbiacityjazz.com [NC]
RewriteRule ^(.*)$ https://www.columbiacityjazz.com/$1 [L,R=301,NC]

RewriteRule ^([^/.]+)/?$ index.php?var1=$1 [QSA,L]

Only additional question … my robots.txt file, sitemap.xml and everything need to live with the site files in teh sub folder, NOT in the root folder now, correct?

I use sub-directories and have a much simpler .htaccess file:
.htaccess

# this may not be required because it should be previously set
# DirectoryIndex index.php

RewriteEngine on
   RewriteCond %{REQUEST_FILENAME} !-f          
   RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L] 

Give it a try and see if it works.

Only additional question … my robots.txt file, sitemap.xml and
everything need to live with the site files in the sub folder, NOT in
the root folder now, correct?

Your robots.txt file should be in the root folder and a reference to wherever your sitemap.xml file is located and possibly the name of the sitemap.xml

** robots.txt**

Sitemap: /Sitemap-001.xml
Sitemap: /Sitemap-002.xml

User-agent: *
Disallow: /myfiles/
Disallow: /private-stuff/
Disallow: /downloads/
Allow:    /public-stuff/


Edit:
Have you a Google or Bing Webmaster Tools accounts? Either or both are very useful for validating that everything is correct and they also supply a vast amount of other information.

Edit:
You may also find this site valuable:
W3.org Html Page Validation

Edit:
I forgot to mention that if you moved your site to a sub-directory then the index.php should be used to include/require/chdir to the new sub-directory.

My question deals with the ability for a subdomain to have its own domain at an unique IP address (for the security certificate). If it’s using the main domain’s cert, you must use it’s domain and your previously secure domain as a subdirectory of that domain (not its own secure cert).

Without the secure server being in this question, it should be pretty easy (just create an Addon Domain and address it normally; it will act the same as it does - except the secure server - as a subdomain/Addon domain).

Regards,

DK

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.