Forum Moderators: phranque
I have several directories under the public_html, and 2 of these directories have their own image folders.
public_html
/my-general-images_files
/red-widgets
/my-red-widget-images_files
/white-widgets
/my-white-widget-images_files
<img src="my-general-images_files/logo.gif"> works okay
<img src="my-red-widgets-images_files/red-widget.gif"> doesn't work
<img src="my red widgets images_files/red-widget.gif"> does work
File paths are correct.
So the home directory accepts the [-], but sub-directories won't.
I have a .htaccess file in the public_html folder, but none in the sub-directories.
.htaccess looks like this
Options +ExecCGI
Options +Includes
AddHandler server-parsed .htm .html
RewriteEngine on
RewriteCond %{HTTP_HOST}!^www.mysite.com [NC]
RewriteCond %{HTTP_HOST}!^$
RewriteRule ^(.*) [mysite.com...] [L,R=301]
RewriteCond %{HTTP_REFERER}!^http?://(www\.)?mysite\.com [NC]
RewriteCond %{HTTP_REFERER}!^http?://([^/\?]+)?google\. [NC]
RewriteCond %{HTTP_REFERER}!^http://216\.239\.(3[2-9]¦[45][0-9]¦6[0-3])\. [NC]
RewriteCond %{HTTP_REFERER}!^http?://([^/\?]+)?yahoo\. [NC]
RewriteCond %{HTTP_REFERER}!^http?://([^/\?]+)?aolsearch\. [NC]
RewriteCond %{HTTP_REFERER}!^http?://([^/\?]+)?gigablast\. [NC]
RewriteCond %{HTTP_REFERER}!^http?://([^/\?]+)?ask\. [NC]
RewriteCond %{HTTP_REFERER}!^http?://([^/\?]+)?msncache\. [NC]
RewriteCond %{HTTP_REFERER}!^http?://([^/\?]+)?archive\. [NC]
RewriteCond %{HTTP_REFERER}!^http?://([^/\?]+)?searchhippo\. [NC]
RewriteRule \.(jpe?g¦png¦gif)$ - [F]
I fixed it by changing the subdirectory image folders (and HTML)to the non-hyphenated version, but was wondering if this is symptomatic of a bad situation or ..?
First, is your URL structure like this:
public_html
/my-general-images_files
/red-widgets
/my-red-widget-images_files
/white-widgets
/my-white-widget-images_files
or like this:
public_html
/my-general-images_files
/red-widgets
/red-widgets/my-red-widget-images_files
/white-widgets
/white-widgets/my-white-widget-images_files
?
Your description implies the former, but your links imply the latter. (For the former case, the second link would normally have to be <img src="../my-red-widgets-images_files/red-widget.gif"> or <img src="/my-red-widgets-images_files/red-widget.gif"> in order to resolve properly for inclusion by a file in the /red-widgets directory.)
Next, upon what information are you basing the conclusion that hyphens "don't work"? Have you tried temporarily omitting them, and that changed the test results, for example?
Lastly, what specifically happens when the browser requests an image? Does the image return a 404 or a 403, or do you get a server error? Anything related to the request in the server error log? (To see the server code, you could use the Firefox Web Developer extension or the Server Headers checker in the WebmasterWorld Control panel.)
If you've got a problem that is really related to hyphens in the URL, then either the host is doing something funny with hyphens in httpd.conf, or the server is misconfigured in some way; Hyphens are treated as a completely-normal character throughout the entire request-response transaction with Apache -- In other words, unlike a space character (encoded as %20), they are not %-encoded or escaped in any manner, and are treated just like any alphanumeric character. Same with underscores, in case that matters.
A very odd case, here.
Jim
or like this:
public_html
/my-general-images_files
/red-widgets
/red-widgets/my-red-widget-images_files
/white-widgets
/white-widgets/my-white-widget-images_files
?"
Yes, like the above .. sorry, I didn't do a very good representation when I posted this.
"Next, upon what information are you basing the conclusion that hyphens "don't work"? Have you tried temporarily omitting them, and that changed the test results, for example?"
Exactly. I added a new images folder, identical but with spaces instead of dashes. Then changed the <img> tag in the same manner. Presto .. it works.
I had tried everything I knew how, then decided to use a simple 'img' directory. That worked, so I progressed one step at a time.
"Lastly, what specifically happens when the browser requests an image? Does the image return a 404 or a 403, or do you get a server error? Anything related to the request in the server error log? (To see the server code, you could use the Firefox Web Developer extension or the Server Headers checker in the WebmasterWorld Control panel.)"
I'm not really sure, I fixed it within an hour. I have LOTS of 403 errors in the error log, but many of them are from a "community" that was hotlinking to my images. The .htaccess file modification, excluding so many sites, is responsible for a lot of them, I'm sure.
"If you've got a problem that is really related to hyphens in the URL, then either the host is doing something funny with hyphens in httpd.conf, or the server is misconfigured in some way; Hyphens are treated as a completely-normal character throughout the entire request-response transaction with Apache -- In other words, unlike a space character (encoded as %20), they are not %-encoded or escaped in any manner, and are treated just like any alphanumeric character. Same with underscores, in case that matters."
What makes it even stranger is the fact that the hyphenated /my-general-images_files works just fine, and the pages in the subdirectories have a link to the logo and background images in the /my-general-images_files, and logo and background shows up on all pages. Ditto with css link.
"A very odd case, here."
I moved the site as a tarball, so it wasn't like I changed any configuration. I checked all permissions, the works. I'm not confident enough yet to dig into the httpd.conf file.
As an afterthought, (I may go back and check) could it be possible that the [-] somehow became "not a [-]" when copying from one OS to another?
If I find something I'll post it here.
Followup:
"I moved the site as a tarball, so it wasn't like I changed any configuration. I checked all permissions, the works. I'm not confident enough yet to dig into the httpd.conf file.
As an afterthought, (I may go back and check) could it be possible that the [-] somehow became "not a [-]" when copying from one OS to another?
If I find something I'll post it here. "
In one directory I had only one page with an image. It definately hadn't worked with the dashes yesterday. So I changed to spaces.
A few minutes ago, I made a new image folder and typed in dashes. It worked.
I'm absolutely sure that the original problem was not a typo as the tarball was untared intact, and it had definately been working on the old host.
Also, I had the same problem in 2 sub-directories.
One of those mysteries that will likely go unsolved.