Zen Cart Logo
Forums / Installing on a Linux/Unix Server / How can I always hide my Zen Cart subfolder address?

How can I always hide my Zen Cart subfolder address?

Locked

Views: 3,992

Results 1 to 4 of 4
This thread is locked. New replies are disabled.
18 Jan 2010, 8:14 AM
#1
adg avatar

adg

New Zenner

Join Date:
Jan 2010
Posts:
10
Plugin Contributions:
0

How can I always hide my Zen Cart subfolder address?

I've successfully installed my zencart in a subfolder of my public_html folder. I can access it as http://domain.com/zencart.

I used my .htaccess to forward naked requests to domain.com to domain.com/zencart. However, I'd like to hide the subfolder name from the browser, if possible. Using the .htaccess I hid the subfolder from the first time you access the site, but clicking any site links, (including home), the url gets rewritten as http://domain.com/zencart/

Down below, I've included the contents of my .htaccess file, if anyone can decipher it and respond as to what I should do next. My suspicion is that I need to configure some Zen Cart native variables. (I checked out what's in configure.php, but couldn't get anything to work from there).

Thanks,

Alex (Brand New Zen Cart User)

Relevant information:
Zen Cart version 1.3.8a [patched]
Hosting: JustHost.com

.htaccess

RewriteEngine on

Change yourdomain.com to be your main domain.

RewriteCond %{HTTP_HOST} ^(www.)?domain.com$

Change 'subfolder' to be the folder you will use for your main domain.

RewriteCond %{REQUEST_URI} !^/zencart/

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 ^(.*)$ /zencart/$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.)?domain.com$
RewriteRule ^(/)?$ zencart/index.php [L]

18 Jan 2010, 8:26 AM
#2
rodg avatar

rodg

Deceased

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

Re: How can I always hide my Zen Cart subfolder address?

adg_:

I've successfully installed my zencart in a subfolder of my public_html folder. I can access it as http://domain.com/zencart.

I used my .htaccess to forward naked requests to domain.com to domain.com/zencart. However, I'd like to hide the subfolder name from the browser, if possible.

Rather than use the convoluted and inefficient rewrites, why not just place your zencart files into the public_html directory?

Alternatively, set your 'document root' to /public_html/zencart/ rather than just /public_html/ ?

Either method is preferable over what you are attempting (unless you happen to have a good reason for wanting URL rewrites).

Cheers
Rod

19 Jan 2010, 5:47 AM
#3
adg avatar

adg

New Zenner

Join Date:
Jan 2010
Posts:
10
Plugin Contributions:
0

Re: How can I always hide my Zen Cart subfolder address?

RodG:

Alternatively, set your 'document root' to /public_html/zencart/ rather than just /public_html/ ?

Is it possible to set the document root from within the .htaccess file? I was checking online, and from what I understand, setting the document root occurs in the httpd.conf file, which I don't have access to with my host (JustHost.com).

Is what you're suggesting possible from within the .htaccess file (available in the public_html directory)?

Thanks.

19 Jan 2010, 6:59 AM
#4
rodg avatar

rodg

Deceased

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

Re: How can I always hide my Zen Cart subfolder address?

adg_:

Is it possible to set the document root from within the .htaccess file?

Errr, well, no, because the 'document root' is actually the 'starting point' for where the server will look for its files, so if this isn't 'right' it isn't going to find the .htaccess file in the first place .........

adg_:

I was checking online, and from what I understand, setting the document root occurs in the httpd.conf file,

For all intents and purposes this is correct (in practice, the http.conf file will 'include' other .conf files when the server starts).

adg_:

which I don't have access to with my host (JustHost.com).

Although you almost certainly won't have direct access to this file you can almost certainly make limited edits indirectly (via cPanel).

Look for the option 'domains' and 'redirect'.

Select http://yourdomain.com from the dropdown menu. Don't place anything after the "/" on the same line.

Then in the 'redirects to' line, enter http://yourdomain.com/zencart.

tick the 'Redirect with or without www' box.
tick the 'Wild Card Redirect' box.

click the 'add' button.

That's it...... now when someone tries to access http://yourdomain.com or
http://yourdomain.com/something they'll be redirected to http://yourdomain.com/zencart. or http://yourdomain.com/zencart/something

Another (possibly better) option would be to add a subdomain instead, eg
store.yourdomain.com (even www.yourdomain.com will work). If you click of the domains/subdomain options of CPanel you will find this pretty self explanitory. It simply asks you to enter the subdomain name and the 'document root' for this subdomain.

Although I don't wish to confuse you any, not many people seem to realise that 'www.somedomain.com' is actually a subdomain of the somedomain.com domain (they THINK the 'www' has something to do with web pages). The fact is, from the server perspective www.somedomain.com and somedomain.com are completely different domains that are isolated from each other. The only reason many (most) sites these days serve the same pages both with and without the 'www' is because the server administrator has set it up that way because the typical user 'expects' it to work that way.

With what you are trying to achieve, by setting up the document root for the 'www' subdomain to be ~/public_html/zencart, and then adding a redirect (as above) to redirect http://yourdomain.com to http://www.yourdomain.com your visitors will never see "/zencart/" as part of the URL (Which I think is what your orginal intent was).

However, as per my original message you will also get the same effect by moving all of your zencart files and folders up one level so that rather than residing in /public_html/zencart/ they simply sit directly in the /public_html directory. If zencart is the only thing that you are serving from your domain then this is by far the most preferred option because it does away with both the rewrites and the redirects.

In short, there really are several options open to you without messing around with URL re-writes.

Cheers
Rod