Basic Question About Loop Section

Dear all,

I'm triying to program one arduino uno board with ethernet shield for sensor control over internet but I faced a problem in loop section. I'm reaching to my arduino sd card (as a web server) from chrome browser when i write 9 if clauses in loop section it is working fine however after 9 if clauses I received this message "page not found"

do you have any suggestions?

do you have any suggestions?

The usual.

Post your code.

#include <SPI.h> 
#include <Ethernet.h> 
#include <SD.h> 
#include <Servo.h> 
Servo myservo;  
                 
 
int pos = 0;    
#define REQ_BUF_SZ   20 


byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(10,0,1,120);   
EthernetServer server(80);       
File webFile;                    
char HTTP_req[REQ_BUF_SZ] = {0}; 
char req_index = 0;              

void setup()
{
    Ethernet.begin(mac, ip);  
    server.begin();           
    pinMode(10, OUTPUT); 
    digitalWrite(10, HIGH);
    pinMode(2, OUTPUT);
    pinMode(3, OUTPUT);
    myservo.attach(9);  
    Serial.begin(9600);        
    
    
    Serial.println("SD kart hazırlanıyor"); 
    if (!SD.begin(4)) {
       // Serial.println("HATA - SD Kart hazır değil");
        return;   
    }
    //Serial.println("TAMAMLANDI - SD Kart hazır");
    if (!SD.exists("index.htm")) { 
        Serial.println("HATA - index.html dosyası bulunamadı");
        return;  
    }
   // Serial.println("TAMAMLANDI - index.htm dosyasına erişildi."); 
}
void loop()
{
    EthernetClient client = server.available();  

    if (client) {  
        boolean currentLineIsBlank = true;
        while (client.connected()) {
            if (client.available()) {   
                char c = client.read(); 
                 if (req_index < (REQ_BUF_SZ - 1)) {
                    HTTP_req[req_index] = c;          
                    req_index++;
                }
                Serial.print(c);    
                if (c == '\n' && currentLineIsBlank) {
                    client.println("HTTP/1.1 200 OK");
                    client.println("Content-Type: text/html");
                    client.println("Connnection: close");
                    client.println();
                    if (StrContains(HTTP_req, "GET / ")
                                 || StrContains(HTTP_req, "GET /index.htm")) {
                        webFile = SD.open("index.htm");        
                    }
                   
                   
                   else if (StrContains(HTTP_req, "GET /1.htm")) {
                     analogWrite(3, 10);
                     webFile = SD.open("1.htm");        
                    }
                   else if (StrContains(HTTP_req, "GET /2.htm")) {
                     analogWrite(3, 20);
					 webFile = SD.open("2.htm");        
                    }
                   else if (StrContains(HTTP_req, "GET /3.htm")) {
                     analogWrite(3, 30);
					 webFile = SD.open("3.htm");       
                    } 
				   else if (StrContains(HTTP_req, "GET /4.htm")) {
                     analogWrite(3, 40);
					 webFile = SD.open("4.htm");        
                    } 
			else if (StrContains(HTTP_req, "GET /5.htm")) {
                     analogWrite(3, 50);
					 webFile = SD.open("5.htm");        
                    } 
                    else if (StrContains(HTTP_req, "GET /6.htm")) {
                     analogWrite(3, 60);
					 webFile = SD.open("6.htm");        
                    }
                    else if (StrContains(HTTP_req, "GET /7.htm")) {
                     analogWrite(3, 70);
					 webFile = SD.open("7.htm");  
					}					 
                    else if (StrContains(HTTP_req, "GET /8.htm")) {
                     analogWrite(3, 80);
					 webFile = SD.open("8.htm");        
                    }
                    else if (StrContains(HTTP_req, "GET /9.htm")) {
                     analogWrite(3, 90);
					 webFile = SD.open("9.htm");        
                    }
                    
                    if (webFile) {
                        while(webFile.available()) {
                            client.write(webFile.read());
                        }
                        webFile.close();
                    }
                    req_index = 0;
                    StrClear(HTTP_req, REQ_BUF_SZ);
                    break;
                }
                if (c == '\n') {
                    currentLineIsBlank = true;
                } 
                else if (c != '\r') {
                    currentLineIsBlank = false;
                }
            } 
        } 
        delay(1);      
        client.stop(); 
    } 
}
void StrClear(char *str, char length)
{
    for (int i = 0; i < length; i++) {
        str[i] = 0;
    }
}
char StrContains(char *str, char *sfind)
{
    char found = 0;
    char index = 0;
    char len;

    len = strlen(str);
    
    if (strlen(sfind) > len) {
        return 0;
    }
    while (index < len) {
        if (str[index] == sfind[found]) {
            found++;
            if (strlen(sfind) == found) {
                return 1;
            }
        }
        else {
            found = 0;
        }
        index++;
    }

    return 0;
}

it is not possible to reach arduino board when i add one more “else if”
and also i checked size of the code. please see the result below.
Binary sketch size: 25,470 bytes (of a 32,256 byte maximum)

With an SD card and Ethernet, you're almost certainly running short (or out) of RAM.

 StrContains

Why reinvent "strstr"?

StrClear

Or "memset"?

thank you for your reply. do you have any suggestions to get rid of this situation?

Try a mega, it has more ram

Use less RAM.

StrContains(HTTP_req, "GET /2.htm"))

could use "strstr_P"

client.println(F("HTTP/1.1 200 OK"));
client.println(F("Content-Type: text/html"));
client.println(F("Connnection: close"));

Keep stuff that doesn't need to be in RAM out of RAM.

Thanks for your replies AWOL and Qdeathstar.