Why getting 404 errors?

Joined
Apr 29, 2023
Messages
19
Reaction score
1
I had this line in some code:
small_digit.src = "Images/M" + i + ".gif"

The code worked fine. It creates an array of 10 images for later use. Then I added an SSL certificate to my site. I immediately started getting 404 errors on the images being loaded.

I had to change it to this and the 404 errors stopped.
small_digit.src = "https://www.dddddddddd.com/ffffffffffff/Images/M" + i + ".gif"

My problem with the above is I assume there are now 10 DNS requests every time the page is loaded.

Is there a way to do what used to be done without having to fully qualify the image? Also, why did the SSL break it? TIA
 
Joined
Jan 24, 2024
Messages
42
Reaction score
7
I had this line in some code:
small_digit.src = "Images/M" + i + ".gif"

The code worked fine. It creates an array of 10 images for later use. Then I added an SSL certificate to my site. I immediately started getting 404 errors on the images being loaded.

I had to change it to this and the 404 errors stopped.
small_digit.src = "https://www.dddddddddd.com/ffffffffffff/Images/M" + i + ".gif"

My problem with the above is I assume there are now 10 DNS requests every time the page is loaded.

Is there a way to do what used to be done without having to fully qualify the image? Also, why did the SSL break it? TIA
To resolve the issue with 404 errors after adding SSL to your site, consider using protocol-relative URLs like this:

JavaScript:
small_digit.src = "//www.dddddddddd.com/ffffffffffff/Images/M" + i + ".gif";

This approach allows the browser to use the same protocol (HTTP or HTTPS) as the current page, avoiding the need to fully qualify the image URLs while ensuring compatibility with SSL.
 
Joined
Apr 29, 2023
Messages
19
Reaction score
1
To resolve the issue with 404 errors after adding SSL to your site, consider using protocol-relative URLs like this:

JavaScript:
small_digit.src = "//www.dddddddddd.com/ffffffffffff/Images/M" + i + ".gif";

This approach allows the browser to use the same protocol (HTTP or HTTPS) as the current page, avoiding the need to fully qualify the image URLs while ensuring compatibility with SSL.

Does this eliminate the DNS request?
 
Joined
Jan 24, 2024
Messages
42
Reaction score
7
Does this eliminate the DNS request?
No, using protocol-relative URLs does not eliminate DNS requests. DNS requests are still necessary for the browser to resolve the domain name ([B]www.dddddddddd.com[/B]) to an IP address. However, subsequent requests to the same domain typically benefit from DNS caching, reducing the overhead of DNS lookups. So while it doesn't eliminate DNS requests entirely, it helps optimize the performance of your web page.
 
Joined
Jan 24, 2024
Messages
42
Reaction score
7
Still wondering why HTTPS breaks the original method?
Switching from HTTP to HTTPS can trigger stricter security policies in browsers, including restrictions on loading insecure content (like images) over an encrypted connection. This likely caused the relative URLs in your code to break. By fully qualifying the image URLs with HTTPS, you ensure secure loading of resources and avoid mixed content issues.
 
Joined
Apr 29, 2023
Messages
19
Reaction score
1
Thanks. So how does one code references during development when the ultimate website does not exist yet?
 
Joined
Jan 24, 2024
Messages
42
Reaction score
7
Thanks. So how does one code references during development when the ultimate website does not exist yet?
During development, you can:

1. Use relative URLs for resources within your project directory.
2. Employ placeholder domain names or configuration files to manage URLs.
3. Utilize local server environments to mimic production conditions without hard-coding specific domains.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,586
Members
45,084
Latest member
HansGeorgi

Latest Threads

Top