News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Moved to subfolder and images not loading

Started by Rommeo, May 16, 2012, 07:59:53 AM

Previous topic - Next topic

Rommeo

I was using smf forum in the root folder, but moved it to subfolder.

so I m using www.mysite.com/forums [nofollow] instead of www.mysite.com [nofollow] now
and I m using cpanel 301 redirection.

actually I could not find documentation for moving to subfolder, and the ones I found was not correct, I even needed to change the values in my smf_themes table. It's not written in any of the sources I have found.

Anyways, my problem is ;
Everything is working right now, but the images that are as attachments are not loading,
If there is a post with attachments (set to full view from settings by default), I need to see the photo, but instead, there is just a gap instead of the photo itself, I have tried to upload another photo, it took sometime but it uploaded and the image loaded, so old images are not loading but new images are loading.

why can it be? what should I change?

Storman™

Quote...and I m using cpanel 301 redirection.

Don't use a redirect - no need !

Quotewhy can it be? what should I change?

Try: Repair Settings php

(Remove redirect first)

Rommeo

Will it reset the settings to defaults or find the one broken and fix it?

Rommeo

tried it, and everything looks fine
all directories are correct..


Rommeo

and weirdly I m downloading images from admin panel,
it s dowloading to my pc, I try to open it, and there is nothing. cant see.

it's just an empty file,

I have set "crypt option" from the section of attachment settings before, can it be the reason?

Storman™

QuoteI have set "crypt option" from the section of attachment settings before, can it be the reason?

Possibly, has the file got an extension like .jpg ..... or does it look like:

106_2c52ead1b6bf0089035c296ba84065f1edbab90b

...or is it's file size zero "0"

MrPhil

Quote from: Storman on May 16, 2012, 08:12:04 AM
Quote...and I m using cpanel 301 redirection.

Don't use a redirect - no need !

If you have no landing page in the root, you will need to do a URL rewrite in .htaccess so that visitors entering just the domain name will be sent on to your forum automatically:
RewriteEngine On
RewriteCond  %{REQUEST_URI}  !^/forums  [NC]
RewriteRule  ^(.*)$   /forums/$1  [L]

I would not do a 301 (permanent) redirect, as in the future when you add a landing page, it could cause temporary problems with cataloged (indexed) site entries. You do want to make sure that your forum uses "/forums" in its links, so that search engine indexes and bookmarks will go straight to the right place (and in the future, won't get confused with your landing page when it's added).

Rommeo

MrPhil you are right
I deactivated 301 but I m using index.php "header location" redirection now ( I have redirection index file in the root ) what do you think?

Storman, you are right too, have that kind of files

106_2c52ead1b6bf0089035c296ba84065f1edbab90b

but file size is not zero
what should I do?


MrPhil

What URL are your missing images using? Does it not include the /forums in their path? Have you ever run the repair_settings? Is everything in Settings.php set up for /forums?

Your /index.php will do nothing to fix file requests (such as images) which are still looking for a forums-less path. I would suggest getting rid of /index.php and using my .htaccess code to do the URL rewriting, which will also fix any paths still using the old path (no /forums). This assumes you're on an Apache server. If it's IIS, you may be able to install some module to make it read .htaccess files, or accomplish the same thing with some other kind of configuration file.

Rommeo

Quote from: MrPhil on May 16, 2012, 12:46:47 PM
What URL are your missing images using? Does it not include the /forums in their path? Have you ever run the repair_settings? Is everything in Settings.php set up for /forums?

Your /index.php will do nothing to fix file requests (such as images) which are still looking for a forums-less path. I would suggest getting rid of /index.php and using my .htaccess code to do the URL rewriting, which will also fix any paths still using the old path (no /forums). This assumes you're on an Apache server. If it's IIS, you may be able to install some module to make it read .htaccess files, or accomplish the same thing with some other kind of configuration file.
I have checked the urls from db and compared it with the working urls. everything is correct. since new images are working compared it with the links of old images which are not working. it s same url. nothing wrong.

As I know what I m doing, all folders and everything are correct too. repair_script could not find any error too.

I have tried the .htaccess way, It s not working also.

new images are working right, old ones are not loading. when you save, size is the same but not opening. its name is something like : 106_2c52ead1b6bf0089035c296ba84065f1edbab90b in db, file size is 50 kb, when you download it s also 50 kb, but when you open nothing in it. it says "creating thumb" but nothing at all. when you look at the posts, there is just gap there, empty image with size more than 0.. none of the images are working which are old ... really need help.

MrPhil

If new images (added since the move) are working, that means the old ones still have an old path stored somewhere. Repair_settings may or may not fix these in all cases. Look in your browser at the "properties" of the images that fail to display and those that do display. If those that fail to display are missing /forums in their path, the .htaccess fix should work. Are you on an Apache server? Is your .htaccess otherwise working (it's in the root /, it's got 644 permissions, etc.). If the old ones show /forums in their path, the problem is somewhere else.

How exactly did you move the files from the root to /forums? Did you use FTP at any point? It's possible that you botched it by transferring in "ASCII" mode rather than "binary". If you used an FTP client in "automatic" mode selection, it may not have realized that these were image files and transferred them in ASCII mode. The only fix will be to go back to the original working files and transfer them again, being careful to force "binary" mode. I'm afraid that any image file previously transferred in the wrong (ASCII) mode is permanently ruined.

Rommeo

yeah !
MrPhil you solved the problem !
it was ASCII I was using, most prob it's cause of that.

Rommeo

possible to fix the files? like converting these ASCII files to binary and upload it again?

MrPhil

It's usually not possible to fix a corrupted image file, once it's been FTP'd in ASCII mode. You'll have to go back to the originals, if you still have them in a site backup (which of course you made before doing the move, right?).

If you're very very lucky, and there was no mix of both x0D0A sequences and x0A bytes in the original file(s), reversing the transfer might fix it. However, that very rarely happens.

How tragic that you didn't simply use your hosting control panel > file manager to move the top level SMF directories down one level, and then the SMF root files down one level. Usually that can be done.

Rommeo

The sources I have found does not even tell about these. if you also notice, noone could figure out the problem which means none are aware of this. I did not move one level down, cause I have changed and modified many files. So as 'not aware of these', instead of uploading more than 50 files one by one, I uploaded all for one time. I hope that whoever are preparing 'howtos' emphasize  these. My first time using SMF but lost one point from my eye really.

MrPhil

When I said "move one level down", what I meant was "move from root to /forum", not a SMF version change. That's usually far more easily done in the hosting control panel than by FTPing everything to a PC and back to the host in a new directory. However, what's done is done.

Note that you should check your attachments too. Since SMF strips off their extensions (filetypes) when it renames them, some FTP clients such as Filezilla will transfer them in ASCII mode, which is a disaster for images, documents, and other binary files. We're having a heated discussion about this over in the Bugs board.

Rommeo

QuoteWhen I said "move one level down", what I meant was "move from root to /forum", not a SMF version change. That's usually far more easily done in the hosting control panel than by FTPing everything to a PC and back to the host in a new directory. However, what's done is done.
I understood that you mean moving from root to forum. I did not change the version of smf. What I mean by change/modify is, I downloaded whole files to my computer, and changed many things, also changed the buttons etc. I m aware of that that can be done by hosting control panel and by other ways including FTP clients. But since I m not aware of this problem that SMF has and no warning anywhere about it, I dowloaded everything (also kept that as back up) and modified and uploaded back(which is the easiest way if SMF does not have a such problem).
Quote
Note that you should check your attachments too. Since SMF strips off their extensions (filetypes) when it renames them, some FTP clients such as Filezilla will transfer them in ASCII mode, which is a disaster for images, documents, and other binary files. We're having a heated discussion about this over in the Bugs board.
Luckily I do not have that much attachments, since as I said it s my first time with smf, but it really lost a point from my eye, for a moment I was thinking of migration to 'xxBB's. I don't know what you support and what developers support, but I m sure that this is one of the reasons that people are not using smf. I don't think that I m the only one who is thinking about migration. And I m sure that some people are backing up by downloading the files is 'ASCII' mode (since all of the ftp clients are in auto mode by default and download them in ascii mode) and they are not aware of that they are not backing up anything actually. I also can not think about the loss when the form is some years old, luckily again my forum is not even 6 months old.. hopin that the developers are reading this topic and posts.

Anyways, thank you for your help and replies. I think they must make you admin here since you are the only one figured out what the problem is.

MrPhil

Well, there'd be some things done differently 'round here if I ran this circus! The first thing I'd do is to tell the developers to set aside all the fun and kewl projects, and put out the next update with a whole bunch of bugs fixed. I don't think we're going to see that, though. :(

Mstcool


Advertisement: