3 improved formatting; corrected spelling & grammar; added link; added translation.
source | link

First: if the rooms were there before ththe bet hakneset, this is allowed because the presence of the bhkbet hakneset cannot cancelcthecancel the way to rooms. By the same svara, if they was build miechatechillawere built milechatechilla in this way it would also be allowed. Shuchan Aruch (1OC 151:5). writes:

ואם היה הדרך עובר קודם שנבנה בית הכנסת מותר

And if the path was there before the bet hakneset was built, it is permitted.

If the rooms were added afterafter the bhkbet hakneset, it's as if we decidedecided to change the use of the bet haknessethakneset and to transform its function to bhka bet hakneset + passage. This is prohibited.Every Every passage needs to be more than a passage, in way to avoid kapandaria equivalency, that is e.g. to use it against rain or sun, even for a talmid chacham, as the Magen Avraham (2).

(1): SAOCOC 151, 5:

ואם היה הדרך עובר קודם שנבנה בית הכנסת מותר

(26): MA sk 6 writes:

שאסור ליכנס בה אלא דבר מצוה [רמב"ם] ועס"א {ולא נכנסים בהם בחמה מפני החמה ובגשמים מפני הגשמים}‏

מגן אברהם ס"ק ב': משמע דזה אפי' לת"ח אסור

First: if the rooms were there before th bet hakneset, this is allowed because the presence of the bhk cannot cancelcthe way to rooms. By the same svara, if they was build miechatechilla in this way(1).

If the rooms were added after the bhk, it's as if we decide to change the use of bet haknesset and to transform its function to bhk + passage. This is prohibited.Every passage needs to be more than a passage, in way to avoid kapandaria equivalency, that is e.g. to use it against rain or sun, even for a talmid chacham (2).

(1): SAOC 151, 5:

ואם היה הדרך עובר קודם שנבנה בית הכנסת מותר

(2): MA sk 6:

שאסור ליכנס בה אלא דבר מצוה [רמב"ם] ועס"א {ולא נכנסים בהם בחמה מפני החמה ובגשמים מפני הגשמים}‏

מגן אברהם ס"ק ב': משמע דזה אפי' לת"ח אסור

First: if the rooms were there before the bet hakneset, this is allowed because the presence of the bet hakneset cannot cancel the way to rooms. By the same svara, if they were built milechatechilla in this way it would also be allowed. Shuchan Aruch (OC 151:5) writes:

ואם היה הדרך עובר קודם שנבנה בית הכנסת מותר

And if the path was there before the bet hakneset was built, it is permitted.

If the rooms were added after the bet hakneset, it's as if we decided to change the use of the bet hakneset and to transform its function to a bet hakneset + passage. This is prohibited. Every passage needs to be more than a passage, in way to avoid kapandaria equivalency, that is e.g. to use it against rain or sun, even for a talmid chacham, as the Magen Avraham (OC 151:6) writes:

שאסור ליכנס בה אלא דבר מצוה [רמב"ם] ועס"א {ולא נכנסים בהם בחמה מפני החמה ובגשמים מפני הגשמים}‏

מגן אברהם ס"ק ב': משמע דזה אפי' לת"ח אסור

2 added 50 characters in body
source | link

First: if the rooms were there before th bet hakneset, this is allowed because the presence of the bhk cannot cancelcthe way to rooms. By the same svara, if they was build miechatechilla in this way(1).

If the rooms were added after the bhk, it's as if we decide to change the use of bet haknesset and to transform its function to bhk + passage. This is prohibited.Every passage needs to be more than a passage, in way to avoid kapandaria equivalency, that is e.g. to use it against rain or sun, even for a talmid chacham (2).

(1): SAOC 151, 5:

ואם היה הדרך עובר קודם שנבנה בית הכנסת מותר

(2): MA sk 6:

שאסור ליכנס בה אלא דבר מצוה [רמב"ם] ועס"א {ולא נכנסים בהם בחמה מפני החמה ובגשמים מפני הגשמים}

מגן אברהם ס"ק ב': משמע דזה אפי' לת"ח אסור

First: if the rooms were there before th bet hakneset, this is allowed because the presence of the bhk cannot cancelcthe way to rooms. By the same svara, if they was build miechatechilla in this way(1).

If the rooms were added after the bhk, it's as if we decide to change the use of bet haknesset and to transform its function to bhk + passage. This is prohibited.Every passage needs to be more than a passage, in way to avoid kapandaria equivalency, that is e.g. to use it against rain or sun (2).

(1): SAOC 151, 5:

ואם היה הדרך עובר קודם שנבנה בית הכנסת מותר

(2): MA sk 6:

שאסור ליכנס בה אלא דבר מצוה [רמב"ם] ועס"א {ולא נכנסים בהם בחמה מפני החמה ובגשמים מפני הגשמים}

First: if the rooms were there before th bet hakneset, this is allowed because the presence of the bhk cannot cancelcthe way to rooms. By the same svara, if they was build miechatechilla in this way(1).

If the rooms were added after the bhk, it's as if we decide to change the use of bet haknesset and to transform its function to bhk + passage. This is prohibited.Every passage needs to be more than a passage, in way to avoid kapandaria equivalency, that is e.g. to use it against rain or sun, even for a talmid chacham (2).

(1): SAOC 151, 5:

ואם היה הדרך עובר קודם שנבנה בית הכנסת מותר

(2): MA sk 6:

שאסור ליכנס בה אלא דבר מצוה [רמב"ם] ועס"א {ולא נכנסים בהם בחמה מפני החמה ובגשמים מפני הגשמים}

מגן אברהם ס"ק ב': משמע דזה אפי' לת"ח אסור

1
source | link

First: if the rooms were there before th bet hakneset, this is allowed because the presence of the bhk cannot cancelcthe way to rooms. By the same svara, if they was build miechatechilla in this way(1).

If the rooms were added after the bhk, it's as if we decide to change the use of bet haknesset and to transform its function to bhk + passage. This is prohibited.Every passage needs to be more than a passage, in way to avoid kapandaria equivalency, that is e.g. to use it against rain or sun (2).

(1): SAOC 151, 5:

ואם היה הדרך עובר קודם שנבנה בית הכנסת מותר

(2): MA sk 6:

שאסור ליכנס בה אלא דבר מצוה [רמב"ם] ועס"א {ולא נכנסים בהם בחמה מפני החמה ובגשמים מפני הגשמים}