Forums / Setting Up Categories, Products, Attributes / redirect not working and host says its not their problem

redirect not working and host says its not their problem

Started by mhulak on 7 May 2012, 12:03 PM · Views: 5,940

Results 21 to 40 of 41
12 May 2012, 10:11 PM
#21
drbyte avatar

drbyte

Sensei

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

redirect not working and host says its not their problem

MHulak:

my server is saying the link syntax is like
2009_04_25_IMG_7615_ED.jpg -> /home/www/michaelhulak/download/2009_04_25_IMG_7615_ED.jpg

and if the link syntax was like
2009_04_25_IMG_7615_ED.jpg -> ../../download/2009_04_25_IMG_7615_ED.jpg
it will work

the file that makes the redirect is /includes/modules/pages/download/header_php.php
however, i am not sure how to test this suggestion

No, the ../../ doesn't make it into /includes/modules/pages/download/header_php.php
The ../../ becomes relative to your store's main index.php file's location, because it's the browser that will interpret the output, not PHP

.
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 May 2012, 10:13 PM
#22
drbyte avatar

drbyte

Sensei

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

Re: redirect not working and host says its not their problem

MHulak:

the pub directory makes a folder during the download however there is nothing inside the folder.
That sounds like a permissions problem. ie: PHP is not being permitted to generate the symlink to put into that folder. Either because it can't write to the folder because PHP doesn't have sufficient write privileges, or because symlinking is disabled for that folder or for the filesystem or for the server in general.

.
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 May 2012, 10:16 PM
#23
drbyte avatar

drbyte

Sensei

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

Re: redirect not working and host says its not their problem

Moderator note: the two threads on the same topic have been merged for continuity of discussion.

.
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 May 2012, 10:20 PM
#24
mhulak avatar

mhulak

New Zenner

Join Date:
Feb 2012
Posts:
78
Plugin Contributions:
0

Re: redirect not working and host says its not their problem

DrByte:

That sounds like a permissions problem. ie: PHP is not being permitted to generate the symlink to put into that folder. Either because it can't write to the folder because PHP doesn't have sufficient write privileges, or because symlinking is disabled for that folder or for the filesystem or for the server in general.

without the ambiguous text added, there is a file in there.

13 May 2012, 6:38 AM
#25
drbyte avatar

drbyte

Sensei

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

Re: redirect not working and host says its not their problem

I've no idea what you mean by "ambiguous text added".


I think you and your host are completely misunderstanding the simple process that Zen Cart is trying to do here.

If your store is set to the default configuration of "Download By Redirect" being enabled, then this is what happens:

a) customer purchases the files
b) customer visits the download links (presented on order-completion screen and/or their my-account order history screen)
c) customer clicks the download link
d) then in the /pub/ folder ZC creates a new folder using a randomly-generated foldername prefixed with a dot
e) ZC looks up the name of the file associated with their purchase and finds the file in the /download/ folder and reads its filesize
f) it instructs PHP to request that the filesystem create a symlink in that /pub/.randomfoldername/ folder which points to the actual file from the /download/ folder (a symlink is like a "shortcut" or "alias" to the original, and NOT an actual copy of the file, since there's no need to make copies when symlinks will serve the purpose perfectly fine as long as symlinking is enabled on your server)
g) then it sends a "filesize and filename" header followed by a "location redirect" header to the browser to take the customer directly to that symlinked file and start a download. This makes the browser talk to Apache directly to obtain the file from the filesystem, without involving Zen Cart in any of the actual download of the file contents.

So, as I've said previously, if your account isn't permitting ZC to create the hidden folder in the /pub/ directory, or isn't being allowed to generate symlinks, or isn't being allowed to follow symlinks, then the downloads won't work. Zen Cart does try to detect whether the symlink was successfully generated and if it can't find the symlink after attempting to create it, normally will fallback to one of the other available methods: either direct-download from the /download/ folder (VERY insecure because the filename link can be shared with "friends" who will never have to pay for those downloads), or the download-by-streaming method which sends the file's contents directly instead of using the symlink/redirect. This latter approach is much more server-intensive and is a less desirable method but may be the only viable option in some server configurations. However it will not generate a 403-forbidden error because the permission to access the page is already granted since the file is being served from a PHP script.

If you are are not using Apache, then you will have to sort out with your hosting company how their webserver engine works instead of traditional configurations of webserver activity.

Also as has been discussed here, if there are characters in the filenames which make for complicated serving as URLs or paths in an HTML or browser request, then things could get interrupted. There will be no errors recorded about this failure because it's very difficult to detect this situation programmatically.

Further, as also mentioned, if the filename doesn't match a pattern that has been whitelisted in the /pub/.htaccess rules then the server's security will block the browser's request for the file. This will be recorded in the server's webserver errorlogs because the webserver is enforcing that rule.

I'm not sure why I'm having to write this here again, as much of this is already explained in the various FAQ articles talking about download delivery methods (which shows the "how it works" and "what each method does and why") and about relocating download folders for added security precautions (that is an advanced concept that may not work for all server configurations). Those articles are worth the read, especially when you're having problems such as you are purporting.

.
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.

13 May 2012, 7:33 AM
#26
rodg avatar

rodg

Deceased

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

Re: redirect not working and host says its not their problem

MHulak:

without the ambiguous text added, there is a file in there.

I don't know if you are still having a problem, but I've just had a successful download of "Bright Red Eyed Bird" (both the .jpg and the .zip).

So, if you are having a problem it is local to your machine (cache files?), OR it is something amiss with whatever file you are using for testing.

Cheers
Rod

ps. Looking at my order history, I noted that you did originally include the file path (wallpaper) as part of the filename. Between that AND the space characters I could easily see how you'd be going around and around in circles.

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.

13 May 2012, 12:10 PM
#27
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,119
Plugin Contributions:
56

Re: redirect not working and host says its not their problem

Did you also modify the .htaccess file in your /download directory? It's got the same file-extension list as the one in the pub folder, so it you don't have .jpg added those files won't be able to be copied over the /pub directory for the customers' downloads.

Hmmm, like RodG said ... it's working now! What did you do to correct your issue?

13 May 2012, 12:22 PM
#28
drbyte avatar

drbyte

Sensei

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

Re: redirect not working and host says its not their problem

lat9:

Did you also modify the .htaccess file in your /download directory? It's got the same file-extension list as the one in the pub folder, so it you don't have .jpg added those files won't be able to be copied over the /pub directory for the customers' downloads.
I must disagree.
The .htaccess in the /download/ folder has NO effect on the files served from the /pub/ folder, even when those files are symlinked.
The .htaccess in the /download folder ONLY applies to files served directly from the /download/ folder. You can have completely different stuff in the /pub/ folder and they won't affect each other. And vice-versa.

.
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.

13 May 2012, 12:28 PM
#29
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,119
Plugin Contributions:
56

Re: redirect not working and host says its not their problem

Thanks for the clarification, DrByte! I apologize for the misinformation.

14 May 2012, 3:03 AM
#30
mhulak avatar

mhulak

New Zenner

Join Date:
Feb 2012
Posts:
78
Plugin Contributions:
0

Re: redirect not working and host says its not their problem

Here is where I am at to clear up all confusion.

The server is Apache so SymLinks should work. It is not a Windows server.

History:
SymLinks were working before. I am not sure when they stopped working. One major change I noticed was one day I got the "zencart new install screen" The solution to get the page back up and running was from /srv/disk1/8133219/www/michael to /home/www/michaelhulak/. After getting the page back up and running, I did a once over the page and discovered the SymLink downloads were no longer working. I put in a ticket to the webserver informing them of the changes needed in the config files and the symlinks no longer working. In the ticket response they told me the symlink is pointing to /home/www/michaelhulak/download/2009_04_25_IMG_7615_ED.jpg when it should be pointing to ../../download/2009_04_25_IMG_7615_ED.jpg. I opened this thread looking for help. I since asked my server to confirm symlinks is working and they told me to put an **htacess **file at the root of the page with Options +FollowSymLinks in it. I already have that in the **htacess **file inside the pub directory. I since asked them to confirm httpd.conf file is setup properly to allow my site to use SymLinks.

Successes:

  • Using direct link instead of SymLinks works.
  • I put extra text within the SymLink creation and this made the redirect fail over to direct. So this is just using direct download. The change was by adding AA in the /includes/modules/pages/download/header_php.php to make the line look like *$link_create_status = @symlink(DIR_FS_DOWNLOAD . $origin_filename, DIR_FS_DOWNLOAD_PUBLIC . $tempdir . 'AA/' . $download_link);*

Details about .htacess
pub folder contains:
## the following line is needed to allow Download-By-Redirect to work
Options +FollowSymLinks

......
<FilesMatch "..(zip|ZIP|gzip|pdf|PDF|mp3|MP3|swf|SWF|wma|WMA|wmv|WMV|wav|epub|JPG|jpg)$">
Order Allow,Deny
Allow from all
</FilesMatch>
*
<IfModule mod_headers.c>
<FilesMatch ".
.(zip|ZIP|gzip|pdf|PDF|mp3|MP3|swf|SWF|wma|WMA|wmv|WMV|wav|epub|JPG|jpg)$">*

download folder contains:
# but now allow just certain necessary files:
<FilesMatch ".
.(zip|ZIP|gzip|pdf|PDF|mp3|MP3|swf|SWF|wma|WMA|wmv|WMV|wav|epub|JPG|jpg)$">
Order Allow,Deny
Allow from all
</FilesMatch>

<IfModule mod_headers.c> <FilesMatch ".*\.(zip|ZIP|pdf|PDF|mp3|MP3|swf|SWF|wma|WMA|wmv|WMV|wav|epub|**JPG|jpg**)$"> * **Details about PUB generated SymLinks** The Pub folder with 777 permissions gets created along with the link within properly. Example */pub/.bqvgmtvqnzjrbhj-1336959970/2009_04_25_IMG_7615_ED.jpg*

Details about Download Folder
Permissions are 755
files for downloading are at the root of the download folder and without spaces or special characters. Example /download/2009_04_25_IMG_7615_ED.jpg

14 May 2012, 8:15 AM
#31
mhulak avatar

mhulak

New Zenner

Join Date:
Feb 2012
Posts:
78
Plugin Contributions:
0

Re: redirect not working and host says its not their problem

My host server came through. They asked me for a sample to test and ensure it is working. I tested it and it seems working fine now. the pub dir is getting the symlink on each download and no more access issues.

i asked them to explain where the problem was and i will post it once i here back from them

i appreciate all the help and support given here. i had a choice of ecommerce solutions. it is obvious i chose the right one.

14 May 2012, 8:24 AM
#32
rodg avatar

rodg

Deceased

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

Re: redirect not working and host says its not their problem

MHulak:

Here is where I am at to clear up all confusion.

Or cause more :unsure:

MHulak:

Details about .htacess

<IfModule mod_headers.c>
<FilesMatch ".
.(zip|ZIP|gzip|pdf|PDF|mp3|MP3|swf|SWF|wma|WMA|wmv|WMV|wav|epub|JPG|jpg)$">*

These tags require maching closing tags

</FilesMatch> </IfModule>

Furthermore, unless there is something placed in between the <FilesMatch> and </FilesMatch> then this section does nothing.

For Apache2 or later the following is recommended:
ForceType application/octet-stream
Header set Content-Disposition attachment

What this does is to force the "Save As" dialog box when the user click on the download links. Without it, unless the mime_types is correctly set, the files could be printed directly to screen as 'raw data'.

MHulak:

Details about PUB generated SymLinks
The Pub folder with 777 permissions gets created along with the link within properly

The Pub folder should already exist. It is only the 'hidden' files/link that gets created upon purchase of a downladable product.
777 folder permissions may cause some servers to crash. 755 or 775 is better (as long as they work).

As I mentioned before, I may appear to be a little(?) pedantic about these things, but a computer is generally far more pedantic and considerably less forgiving.

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.

14 May 2012, 8:35 AM
#33
mhulak avatar

mhulak

New Zenner

Join Date:
Feb 2012
Posts:
78
Plugin Contributions:
0

Re: redirect not working and host says its not their problem

the htaccess files had closing tags and all. i just posted the changes.

anyways, my server responded saying the issue was

*Our system administrators changed the path in the code (as we described earlier the path should be something like this 'ln -s ../download/wallpaper/...'). We set this for your files and the problem is resolved now. We are glad to know that you are satisfied from our service. *

14 May 2012, 9:11 AM
#34
rodg avatar

rodg

Deceased

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

Re: redirect not working and host says its not their problem

MHulak:

the htaccess files had closing tags and all. i just posted the changes.

I thought that was probably the case, BUT some/many people do take these things literally, and it would be easy to assume that since you didn't show them then they probably aren't needed.

MHulak:

anyways, my server responded saying the issue was

*Our system administrators changed the path in the code (as we described earlier the path should be something like this 'ln -s ../download/wallpaper/...'). We set this for your files and the problem is resolved now. We are glad to know that you are satisfied from our service. *

I really don't wish to cause you pain or distress, but this puts me a little on edge. There shouldn't be any need for your system admins to have put in any such links in the first place, and when they state "We set this for your files and the problem is resolved now" makes me even more nervous because we have no way of knowing what their 'new settings' are. Have they added another needless link?

Being the devils advocate, and looking at the worst possible scenario, let us assume you have something like this:

*/download/wallpaper/somefile.jpg

*and another like */download/portraits/somefile.jpg *

If your host has made a symbolic link from /download/wallpaper/ to /download/ (which will take care of your 'wallpaper' files), then what do you think is going to happen if the download is for the /portrait/somefile.jpg file (which probably doesn't have this same 'fix') ?

I'm NOT saying that this IS the case, but if it were, you will soon run into even more (needless) problems. It would be wise for you to test this scenario just in case. It will be easier to rectify the problem while it is still 'fresh' than have to start another thread or open another support ticket in a few weeks time where the whole cycle will start again.

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.

14 May 2012, 10:12 AM
#35
mhulak avatar

mhulak

New Zenner

Join Date:
Feb 2012
Posts:
78
Plugin Contributions:
0

Re: redirect not working and host says its not their problem

The system administrators added the following lines :

222 // make link via relative path:
223 $link_create_status = @symlink('../../download/'. $origin_filename, DIR_FS_DOWNLOAD_PUBLIC . $tempdir . '/' . $download_link);

in your '/home/www/michaelhulak/includes/modules/pages/download/header_php.php' file and disabled/commented the 220 line of the same file.

I tested this with the original subdirectories and files with spaces in it and they too work. I put Yellow Trout Lily in Toronto 1.94 MB Flower_Macros/2012 04-18 IMG_2088.zip in Flower Macros $0.00 to show and test

14 May 2012, 10:47 AM
#36
mhulak avatar

mhulak

New Zenner

Join Date:
Feb 2012
Posts:
78
Plugin Contributions:
0

Re: redirect not working and host says its not their problem

was the dir fs download path was faulty.

i have what i believe was generated upon installation

define('DIR_FS_DOWNLOAD', DIR_FS_CATALOG . 'download/');
define('DIR_FS_DOWNLOAD_PUBLIC', DIR_FS_CATALOG . 'pub/');
define('DIR_WS_UPLOADS', DIR_WS_IMAGES . 'uploads/');
define('DIR_FS_UPLOADS', DIR_FS_CATALOG . DIR_WS_UPLOADS);
define('DIR_FS_EMAIL_TEMPLATES', DIR_FS_CATALOG . 'email/');

14 May 2012, 11:16 AM
#37
rodg avatar

rodg

Deceased

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

Re: redirect not working and host says its not their problem

MHulak:

The system administrators added the following lines :
223 $link_create_status = @symlink('../../download/'. $origin_filename, DIR_FS_DOWNLOAD_PUBLIC . $tempdir . '/' . $download_link);

I'm undecided as to whether to call them idiots or too smart for their own good.

They've modified one of the core files in order to fix a user error in one (or both) of the configure.php files.
I hope you have a very good memory, because in 6 or 12 months time (or whenever the next zencart update is released) you will need to remember and re-implement these changes. It would be FAR easier to fix the configuration error and you'll never have to worry about it again.

MHulak:

I tested this with the original subdirectories and files with spaces in it and they too work. I put Yellow Trout Lily in Toronto 1.94 MB Flower_Macros/2012 04-18 IMG_2088.zip in Flower Macros $0.00 to show and test

I think the fact that this worked is more luck than anything else. The file that gets downloaded is called "2012_04-18_IMG_2088.zip", so something has converted the spaces to underscores for you.
On a personal level, I think this is a horrible filename... Call me strange if you like, but If were to purchase a downloadable product called "Yellow Trout Lily" I would actually be expecting to download a file with a similar name, eg YellowTroutLily.zip .. I'd have a heck of a time finding this file when it's called "2012_04-18_IMG_2088.zip". Heck, the date doesn't even reflect the date I downloaded or purchased it. :no:

Unlike most of my previous input, this one is just personal opinion rather than technical requirements.

Do with this what you will.

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.

14 May 2012, 9:34 PM
#38
drbyte avatar

drbyte

Sensei

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

Re: redirect not working and host says its not their problem

MHulak:

Here is where I am at to clear up all confusion.

The server is Apache so SymLinks should work. It is not a Windows server.

History:
SymLinks were working before. I am not sure when they stopped working. ** One major change I noticed was one day I got the "zencart new install screen" The solution to get the page back up and running was from /srv/disk1/8133219/www/michael to /home/www/michaelhulak/.** After getting the page back up and running, I did a once over the page and discovered the SymLink downloads were no longer working.
So, clearly your host changed how/where your data is stored on your server.
And in the aftermath of trying to fix the mess created by doing that, you or they neglected to update all the paths properly in your configure.php files to reflect the new locations of files/folders.

.
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.

14 May 2012, 11:19 PM
#39
mhulak avatar

mhulak

New Zenner

Join Date:
Feb 2012
Posts:
78
Plugin Contributions:
0

Re: redirect not working and host says its not their problem

i originally asked then this.
*
Subject: DIR_FS_CATALOG

SatMay 5 2012 4:19pm
last night my https://www.michaelhulak.com was working correctly. this morning the page was not working. after some time i got it working again.

was my folder/directory information moved or changed? what happened to my page last night? will this happen again?

SatMay 5 2012 4:28pm - Paul Allen Rate this answer: (Poor) (Excellent)
Hello Michael,

Thank you for contacting us.

Please be informed that we never modify/move/delete or do any interaction whatsoever on our customer's accounts without their consent and knowledge.

Whatever it was, it was not caused by a direct or indirect action from our side. If this happens again, please let us know immediately and do not take action to repair the site so we can investigate and find the possible cause.*

15 May 2012, 2:26 AM
#40
rodg avatar

rodg

Deceased

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

Re: redirect not working and host says its not their problem

MHulak:

Please be informed that we never modify/move/delete or do any interaction whatsoever on our customer's accounts without their consent and knowledge.

Whatever it was, it was not caused by a direct or indirect action from our side. If this happens again, please let us know immediately and do not take action to repair the site so we can investigate and find the possible cause.*

MHulak:

** The solution to get the page back up and running was from /srv/disk1/8133219/www/michael to /home/www/michaelhulak/.**

One of these contradicts the other.

Who provided this solution?

Cheers
Rod

PS. For what its worth, ***/srv/disk1/8133219/www/michael ***was a problem just waiting to happen. You should never have used it in the first place (unless the server was misconfigured)

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.