Zen Cart Logo
Forums / Installing on a Linux/Unix Server / Moved Servers .htaccess loop issue

Moved Servers .htaccess loop issue

Views: 4,534

Results 1 to 10 of 10
10 Sep 2013, 6:52 PM
#1
gabstero avatar

gabstero

Zen Follower

Join Date:
Nov 2007
Posts:
342
Plugin Contributions:
0

Moved Servers .htaccess loop issue

Hi Gang -

So I moved a perfectly working zencart (v1.3.7.1) from hostmonster to bluehost (same platform, etc.), but this time I have zencart sitting cozily in its own subdirectory (as an Added Domain) on my new root as opposed to the old one where it resided in the main root.

Previous server location: /home/public_html/
Current server location: /home/public_html/zencart/

I moved all files, updated the paths in /configure.php and (helped by the good folks on this forum - THANK YOU!), but I am getting some nasty redirect loops, and I feel like something needs to be changed in the .htaccess file, but I am note sure what and how.
I also wanted to mention that I have also an SSL certificate applied to the domain (the added one) and I do have a dedicated IP.

The server error logs shows this error if it helps:

[warn] RewriteCond: NoCase option for non-regex pattern '-f' is not supported and will be ignored.

If it helps, the website is http://gabkits.com

Any hints will be of GREAT help!!

thank you!
gabstero

10 Sep 2013, 7:26 PM
#2
lhungil avatar

lhungil

Totally Zenned

Join Date:
Feb 2012
Location:
mostly harmless
Posts:
1,818
Plugin Contributions:
4

Re: Moved Servers .htaccess loop issue

gabstero:

... this time I have zencart sitting cozily in its own subdirectory (as an Added Domain) on my new root as opposed to the old one where it resided in the main root. ...
You should NEVER place a "added domain" in the webroot of another website. This can cause a number of headaches, not the least of which are making mod_rewrite directives far more complicated (remember ".htaccess" files in parent directories are also evaluated).

To mitigate all kinds of fun issues, I'd recommend moving the physical location of the "added site". You can usually configure this from cpanel, otherwise you will have to ask your hosting provider.

EX:
/home/public_html/ (primary site)
/home/gabkits/public_html/ (added site)

gabstero:

...

[warn] RewriteCond: NoCase option for non-regex pattern '-f' is not supported and will be ignored.

> ...
Edit the ".htaccess" file: remove the "-f" from the end of all RewriteCond lines and make sure no RewriteBase line is present.
10 Sep 2013, 7:46 PM
#3
gabstero avatar

gabstero

Zen Follower

Join Date:
Nov 2007
Posts:
342
Plugin Contributions:
0

Re: Moved Servers .htaccess loop issue

Thanks for the tips lhungil.

To make issue more complicated, my primary domain (other than the one in discussion, I'll call it primarydomain.com), sits in a separate folder (just to keep the main public_html/ root free of clutter.
Then I have a .htaccess file in the root doing this as per BlueHost's instructions:

# Use PHP5.4 as default
AddHandler application/x-httpd-php54 .php


# BlueHost.com
        # .htaccess main domain to subdirectory 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 photogabi.com to be your main domain.
        RewriteCond %{HTTP_HOST} ^(www.)?primarydomain.com$
        # Change 'subdirectory' to be the directory you will use for your main domain.
        RewriteCond %{REQUEST_URI} !^/primarydomain/
        # Don't change these line.
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        # Change 'subdirectory' to be the directory you will use for your main domain.
        RewriteRule ^(.*)$ /primarydomain/$1
        # Change primarydomain.com to be your main domain again.
        # Change 'subdirectory' to be the directory 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.)?primarydomain.com$
        RewriteRule ^(/)?$ primarydomain/index.html [L]

thanks,
g

10 Sep 2013, 8:11 PM
#4
gabstero avatar

gabstero

Zen Follower

Join Date:
Nov 2007
Posts:
342
Plugin Contributions:
0

Re: Moved Servers .htaccess loop issue

Just got back from chatting with support on having a separate public_html folder for the AddOn Domain.

"Unfortunately not possible to have this set up on a shared server.
There is only 1 public_html. What you can do is create a sub folder in the public_html for this site to load from"

thanks,
g

10 Sep 2013, 8:32 PM
#5
gabstero avatar

gabstero

Zen Follower

Join Date:
Nov 2007
Posts:
342
Plugin Contributions:
0

Re: Moved Servers .htaccess loop issue

Thought of posting the full .htaccess I have in the gabkits subfolder:

AddHandler application/x-httpd-php5 .php

<IfModule mod_rewrite.c>
# For security reasons, Option followsymlinks cannot be overridden.
#Options +FollowSymLinks
RewriteEngine On

#Aji: This was already existing for canonicalization.
RewriteCond %{HTTP_HOST} ^(www\.)?gabkits\.gabkits\.com [NC,OR]
RewriteCond %{HTTP_HOST} ^!www\.gabkits\.com [NC]
RewriteRule ^(.*)$ http://www.gabkits.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^gabkits.com [NC]
RewriteRule ^(.*)$ http://www.gabkits.com/$1 [R=301,L]
RewriteCond %{REQUEST_URI} ^/gabkits($|/.*$)
RewriteRule ^.* http://www.gabkits.com%1 [R=301,L]

#Aji (May 24, 2008, 12:49 IST): This will produce a different robots.txt for https, blocking all files
RewriteCond %{SERVER_PORT} 443 [NC]
RewriteRule ^robots.txt$ robots_ssl.txt [L]

</IfModule>

#### BOF SSU
# For security reasons, Option followsymlinks cannot be overridden.
#Options +FollowSymLinks
RewriteEngine On
# Change "/zencart/ to the correct setting
# if your site is located at root folder, then you should have RewriteBase /
# Go to your include/configure.php, this value should be the same with the value of DIR_WS_CATALOG
#RewriteBase /gabkits/

# Deny access from .htaccess
RewriteRule ^\.htaccess$ - [F]

RewriteCond %{SCRIPT_FILENAME} [OR]
RewriteCond %{SCRIPT_FILENAME} -d
RewriteRule .* - [L]

RewriteRule ^(.+) index.php/$1 [E=VAR1:$1,QSA,L]
#### EOF SSU

<Files 403.shtml>
order allow,deny
allow from all
</Files>

Thanks,
g

10 Sep 2013, 8:52 PM
#6
lhungil avatar

lhungil

Totally Zenned

Join Date:
Feb 2012
Location:
mostly harmless
Posts:
1,818
Plugin Contributions:
4

Re: Moved Servers .htaccess loop issue

Reading back over your first post... Have a question, did you update both of Zen Carts configuration files after the move? If not, make sure the paths specified in "/includes/configure.php" and "/admin/includes/configure.php" are correct.

gabstero:

...
To make issue more complicated, my primary domain (other than the one in discussion, I'll call it primarydomain.com), sits in a separate folder (just to keep the main public_html/ root free of clutter.
... Then I have a .htaccess file in the root doing this as per BlueHost's instructions: ...
EWWW. I far prefer each domain with it's own non public facing folder to store sensitive data (such as log files, caches, etc) and document root (public facing folder). Just makes things simpler.

You can probably start by editing the ".htaccess" file in the root "/zencart/". Remove all the rules and see if you can get to the site (no HTTP 500). If you can, selectively add things back in (starting with the rules for the SSU plugin).

<rant>
They really said you cannot add additional document roots? I've yet to hear this answer from any of the hosting providers I have used. I wonder if this is a case of "I do not know how to do this so I'll say we do not support this"? But I could be wrong (and if I am, this host does not appear to have a very well thought out configuration for hosting multiple domains on a shared hosting plan).

If you don't mind doing things yourself and have access to cPanel... You could check and see if you can configure different document roots yourself via cPanel...

[Attachment no longer available]

</rant>

NOTES: Meant to look for and remove the [NC] on the RewriteCond with -f in my last post. Whoops! Also SSU is no longer actively supported on Zen Cart > 1.3 at this time.

10 Sep 2013, 9:12 PM
#7
gabstero avatar

gabstero

Zen Follower

Join Date:
Nov 2007
Posts:
342
Plugin Contributions:
0

Re: Moved Servers .htaccess loop issue

Thanks a lot!

So, I removed everything (commented out) from the .htaccess that sits in the /public_html/gabkits folder. Now I am getting a blank page on http://gabkits.com - buy hey - no server error! :-)
I'll start adding the rules back as you mentioned.

Unfortunately my addon CPanel interface keeps me locked to my primary public_html root (see below):

Attachment 13050

I'll start adding the SSU rules back one by one and report back.

Thanks so much for help - just wanted to let you know that it is appreciated a LOT!

g

10 Sep 2013, 9:22 PM
#8
gabstero avatar

gabstero

Zen Follower

Join Date:
Nov 2007
Posts:
342
Plugin Contributions:
0

Re: Moved Servers .htaccess loop issue

the strangest thing about adding the rules back one one is that the URL changes immediately from:

http://gabkits.com
to
http://gabkits.com/zc_install/index.php

and I get 404.

hmm..

thanks,
g

11 Sep 2013, 12:24 PM
#9
lhungil avatar

lhungil

Totally Zenned

Join Date:
Feb 2012
Location:
mostly harmless
Posts:
1,818
Plugin Contributions:
4

Re: Moved Servers .htaccess loop issue

Did you update the "configure.php" files? Can you post the main configure.php file contents (minus any passwords of course)?

Also strange you are getting a generic 404 and not the Zen Cart 404... From the SSU rules: "RewriteRule ^(.+) index.php/$1 [E=VAR1:$1,QSA,L]". This line should be forcing all requests for files / directories which do not exist (and have not matched a previous RewrteRule w/ the [L] flag to Zen Cart). Hmmmm...

11 Sep 2013, 5:31 PM
#10
lhungil avatar

lhungil

Totally Zenned

Join Date:
Feb 2012
Location:
mostly harmless
Posts:
1,818
Plugin Contributions:
4

Re: Moved Servers .htaccess loop issue

Issue resolved. Needed to remove some unnecessary 301 redirects (attempting to change the hostname). Also needed to update both of the "configure.php" files with the file system paths for the new server.

  // Define web relative location of the store (in the URL)
  define('DIR_WS_CATALOG', '/');
  define('DIR_WS_HTTPS_CATALOG', '/');

  // Define web relative location of the admin (in the URL)
  $t1 = parse_url(HTTP_SERVER);$p1 = $t1['path'];$t2 = parse_url(HTTPS_SERVER);$p2 = $t2['path'];
  define('DIR_WS_ADMIN', preg_replace('#^' . str_replace('-', '\-', $p1) . '#', '', dirname($_SERVER['SCRIPT_NAME'])) . '/');
  define('DIR_WS_HTTPS_ADMIN', preg_replace('#^' . str_replace('-', '\-', $p2) . '#', '', dirname($_SERVER['SCRIPT_NAME'])) . '/');

  // Define physical server location of the store and admin
  define('DIR_FS_CATALOG', '/home2/photogab/public_html/gabkits/');
  define('DIR_FS_ADMIN', '/home2/photogab/public_html/gabkits/admin/');

  // Define the physical path to the SQL cache
  define('DIR_FS_SQL_CACHE', '/home2/photogab/public_html/gabkits/cache');