Zen Cart Logo
If this is your first visit, check our documentation. To post, register or login.
Forums / Installing Zen Cart / Installing on a Windows Server / Can I edit the root or "hub" index.php file to point to diferent installs?

Can I edit the root or "hub" index.php file to point to diferent installs?

Started by lrs on 9 Jan 2011, 12:33 AM · Views: 4,491

Results 1 to 7 of 7
9 Jan 2011, 12:33 AM
#1
lrs avatar

lrs

Zen Follower

Join Date:
Feb 2006
Posts:
130
Plugin Contributions:
0

Post #1 by lrs

Would it work to edit the root index.php file to point to a different folder installation of ZenCart rather than using some other kind of file to redirect you to the store folder like an Index.htm or .htaccess (not sure on the spelling of that file)?

I was thinking it might be nice to be able to have a backup store already installed in one folder and the working store in another, then all you would need to do is edit the "hub" or root index.php file to point to a different folder and your additional install would work immediately without the need to change any other files.

This would also work when upgrading by creating a new folder for the upgrade then just changing the root index.php.

Is there a BETTER way to do that that allows you to have more than one fully ready shops installed with the ability to select one of them by editing that file?

I don't want an HTML type root page that redirects them to the store, or one with a button to click to enter the store. I want it to go seamlessly right to the shop but want the ability to change the shop at will by only editing ONE file!

9 Jan 2011, 3:40 AM
#2
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Post #2 by kobra

And why would one want to do this??

It would fully mess up any site ranking, SE links etc

If you desire a different look for the shop all that is required is another template installed and from the admin you can switch the template and have a different look for the store and not break any SE links

Zen-Venom Get Bitten

9 Jan 2011, 3:45 AM
#3
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Post #3 by rodg

LRS:

Would it work to edit the root index.php file to point to a different folder installation of ZenCart rather than using some other kind of file to redirect

This can be done with minor edits to the two configure.php files.

Cheers
Rod

NOTE: We are sorry that Rod is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

Ozpost - The Ultimate Shipping module for Australian Merchants. Click these links for its Homepage, or Download from Zen-Cart.com.

9 Jan 2011, 6:25 AM
#4
lrs avatar

lrs

Zen Follower

Join Date:
Feb 2006
Posts:
130
Plugin Contributions:
0

Post #4 by lrs

RodG:

This can be done with minor edits to the two configure.php files.

Cheers
Rod

OK.....

How would you do that?

I know how to edit configure.php file so to show the correct directories where the store and the admin are but how would you send someone who logs on to the web site into a store that is in a sub folder? You can't just copy the index.php file out of that sub directory....

This is what I want to do.

someone navigates to www.mystore.com

On that site there are several zencart installs but only ONE is active, each in its own subfolder with its own index.php file, its own admin folder etc, each using their own separate database.

www.mystore.com/store1/index.php
www.mystore.com/store2/index.php
www.mystore.com/store3/index.php

I want to be able to randomly turn off any two of those installs by editing only ONE file that resides in the root of www.mystore.com

What file can you put in the root of www.mystore.com, BESIDES an index.html with a redirect to the store folder, that will load zencart directly without a having to click on something or have it redirect the shopper? (some browsers will alert the shopper if they are being redirected.... I don't want that to happen.)

I haven't tried it but I am gussing if you just copied the index.php file from www.mystore.com/store2 out to the root www.mystore.com, even if you put the right directory info in it, it isn't going to work......or is it?

9 Jan 2011, 8:02 AM
#5
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Post #5 by rodg

LRS:

OK.....

How would you do that?

I probably wouldn't. I don't see the need or the point of what you are trying to achieve.

LRS:

I know how to edit configure.php file so to show the correct directories where the store and the admin are

okaaaayyyy......

LRS:

but how would you send someone who logs on to the web site into a store that is in a sub folder?

The folder/subfolder that a person sees when they connect to the 'root' of the domain is a function/setting of the web server. On a shared system this is usually handled via the .htaccess file.

LRS:

You can't just copy the index.php file out of that sub directory....

index.php is one of the default filenames that a webserver will look for if someone connects to the server without specifying the name of the file to be loaded.

Whether you can copy any given index.php file into any other folder and have it work is going to be dependent on the contents of the file itself.

LRS:

This is what I want to do.

someone navigates to www.mystore.com

On that site there are several zencart installs but only ONE is active, each in its own subfolder with its own index.php file, its own admin folder etc, each using their own separate database.

www.mystore.com/store1/index.php
www.mystore.com/store2/index.php
www.mystore.com/store3/index.php

I want to be able to randomly turn off any two of those installs

There is no function or feature in any webserver that I know of that allows an installation to be 'turned off' (or on) as such... The best they can do is allow or disallow access to it.

Having said that, I'm sure you have something more in mind here, or are you simply forgetting the possility that someone may actually point their web browser directly to any one of those stores regardless of which one you decide should be 'active'?

LRS:

by editing only ONE file that resides in the root of www.mystore.com

Again, assuming this can be done (heck, it is a computer program, we can make it do what we want, within the constraints of other software that we are dependant upon ) what do you think/expect will happen if someone points thier browser directly to the store(s) in the "subfolders".

I'll tell you.... the page/store will load, unless you take additional steps to explicitely prevent it..... can this be done in the same 'one file' - Yes, quite probably, as long as it is an .htaccess file. It can't be done as an index file because you have no assurance that any given index file will actully be loaded to begin with.. As stated above, this is a default file that gets loaded if no other filename is provided.. A URL entered such as www.mystore.com/store3/index.php will completely bypass www.mystore.com/index.php so you can completely foget this option.

LRS:

What file can you put in the root of www.mystore.com, BESIDES an index.html with a redirect to the store folder,

As just stated, an index.html, index.php, etc file will not work for what you have stated you are trying to achieve. you need to be working at the server level, which means the .htaccess file(s).

LRS:

that will load zencart directly without a having to click on something or have it redirect the shopper? (some browsers will alert the shopper if they are being redirected.... I don't want that to happen.)

I'm a little rusty on this one and can't recall whether the URL rewrite feature of the .htaccess file (which is what you'll be needing to use) triggers a redirect alert on the webbrowser(s) or not.. it may even depend whether it is set as a temporary or permanent redirect. You'll need to research this for yourself.

LRS:

I haven't tried it but I am gussing if you just copied the index.php file from www.mystore.com/store2 out to the root www.mystore.com, even if you put the right directory info in it, it isn't going to work......or is it?

Clearly it isn't going to be any good just having the zencart index.php file in the root folder without all of its support files and folders, and it seems you are under the impression that the 'index' file(s) are some kind of mandatory control file.. They are nothing of the sort, they are just regular php/html file(s) that may or may not be loaded.

So, how to achieve what you think you need?.... You've already set up three completely independent stores which means you know how to control where zencart loads its files from, which is where I thought you were getting stuck, so you now have two problems to solve.

  1. How to make any one of these stores the 'active' one,
  2. How to prevent users from accessing the inactive ones.

The first problem can be solved by setting the 'document root' to be the store folder you wish to be 'active' - This is VERY easy to do if you have access to cPanel (or similar), otherwise you'll need to create and/or edit the .htaccess file at the top level of your site manually.

The second problem has several solutions. The quickest/easist is to add password protection to the inactive folders, a better method would be add commands to the .htaccess file to rewrite the inactive URL's so they point to the active one... I'm pretty sure this can all be achieved in a single .htaccess file in the top level of your website...

Is it possible to manipulate the configure.php files to achieve the same/similar thing, I still can't see why not. ...it will require changing both files, so it is not the one file solution that you are after. Just keep in mind which config files are going to be used (those located in your default store/URL) as well as the changes needed to make zencart use a different set of files.
This still wouldn't prevent users from entering the other store URL's directly though (thus bypassing the default store and whatever its current settings may be).

Have fun
Rod

NOTE: We are sorry that Rod is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

Ozpost - The Ultimate Shipping module for Australian Merchants. Click these links for its Homepage, or Download from Zen-Cart.com.

9 Jan 2011, 10:37 AM
#6
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Post #6 by drbyte

LRS:

I was thinking it might be nice to be able to have a backup store already installed in one folder and the working store in another, then all you would need to do is edit the "hub" or root index.php file to point to a different folder and your additional install would work immediately without the need to change any other files.With respect, I think you're jumping to a suggested "fix" before properly explaining what real "business problem" or "need" you're trying to solve. What specific "pain point" are you thinking doing this is going to fix for you?
LRS:

This would also work when upgrading by creating a new folder for the upgrade then just changing the root index.php.Not really, since the recommended approach to upgrading does not include taking a "different" site live. It is recommended to stage the upgrade in a separate store, work out any kinks, and then RE-DO the upgrade on the LIVE store directly after taking it down for maintenance. That redoing of the upgrade should take only a few minutes since you've already lined up all the actual changes to be done. This recommended way also prevents you from losing any sales while testing your upgrade, and prevents you from having your store offline for hours/days while getting it ready to go. > LRS:

Is there a BETTER way to do that that allows you to have more than one fully ready shops installed with the ability to select one of them by editing that file?Given that any typical website will have only one store and no need to switch suddenly to a different one, I'm still unclear as to why you think this is a solution? What specific business problem are you trying to fix?

As I said, I mean no disrespect. I'm just confused at the approach you're taking and the "why" behind it. I get the sense that maybe there's something else that needs to be changed in the way you're doing things or the way you're looking at things. There seems to be important information missing from the picture here. At least, that's how I perceive it on first and second readings.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

12 Jan 2011, 11:36 PM
#7
celtic avatar

celtic

Zen Follower

Join Date:
Feb 2010
Posts:
154
Plugin Contributions:
0

Post #7 by celtic

LRS:

Would it work to edit the root index.php file to point to a different folder installation of ZenCart rather than using some other kind of file to redirect you to the store folder like an Index.htm or .htaccess (not sure on the spelling of that file)?

Without getting into the argument about why you might want to do this, an answer is that (after a brief gander at things) ZC is not a million miles away from being able to do this sort of switch between websites.

At present it loads index.php, which loads application_top.php which loads configure.php.

As configure.php defines both the DIR_WS_CATALOG and DIR_FS_CATALOG, if these were defined within the index.php file itself with some other modification to those three files, it should be possible to do what you want.

By the way, the MAGENTO e-commerce system allows this sort of setup 'out of the box' as it were.

One reason for doing this is when a number of domains are parked on the same hosting platform and you want different sites to show depending on the domain chosen. (You can also do this using the .htaccess file, so there's no specific need to have the feature in the software.)

One main reason for Magento allowing this setup though is for multiple websites to be created (say various departments in a larger 'megastore') which focus on specific product types (electronics, books, etc. ala Amazon style) but for all products to be stored in a single back-end system (which is different to what you are asking for in having each database separate) but that's a possible use for this type of setup - and it is a powerful feature within Magento so worth considering making possible for ZC too at some point I reckon.

(BTW, in your original explanation, there's no way to 'turn off' the two stores that index.php doesn't redirect to, because all 3 stores exist within your webspace, so anyone could just type the url of any of the stores in order to go there. The only way to prevent this, other than deleting the files off the drive, is to use a .htaccess file to block access, and if you're going to do this in .htaccess then there's no point doing all the edits to index.php etc.)