Reputation: 128
when I turned on SSL on my Drupal 7 website I've also turned on module to replace all images, styles, etc. path from
src="http://example.com/path/to/my/image.jpg"
to
"//example.com/path/to/my/image.jpg"
.
I've noticed, that right now I have a lot of page not found (404) in my log, and they look like https://example.com/example.com/path/to/my/image/jpg
.
Do You know, what can I do to prevent this 404 errors? Maybe some htaccess redirect? Do You think It's fault of old web browsers which don't support protocol-relative URL?
Upvotes: 0
Views: 379
Reputation: 31
I had exactly the same problem and this addition to .htaccess seems to have resolved it for me:
RewriteRule ^//example.com/(.*)$ /$1 [NC,L,R=301]
My theory is that those 404 errors were the result of some poorly written bots crawling the website or some non-standard browsers that don't support protocol relative URLs. Normal browsers add the proper protocol to the URLs before accessing the server, so in theory the server shouldn't ever see such URLs in the requests.
Upvotes: 1