Short answer. The landlord cannot simply go straight after the subtenant as the first target. The sublessee is only subsidiarily liable to the landlord for rent owed by the main tenant, and even then only up to the amount the subtenant himself owes under the sublease at the time of the landlord's demand.
What the law says
The sublessee is subsidiarily liable to the lessor for any rent due from the lessee. However, the sublessee shall not be responsible beyond the amount of rent due from him, in accordance with the terms of the sublease, at the time of the extra-judicial demand by the lessor.
Civil Code, Article 1652 — The Sublessee's Liability to the Owner. Read the full provision →
The subtenant is a backstop, not the first stop
The law makes the sublessee subsidiarily liable to the lessor for any rent due from the lessee. Subsidiary is the key word. It means the subtenant stands behind the main tenant, not beside them. The person primarily on the hook for the rent is the original tenant who signed the lease with the owner. The subtenant becomes answerable to the owner only in support of that primary obligation, typically where the main tenant has not paid. So an owner cannot treat the subtenant as the first and equal target for the whole rent; the main tenant's obligation comes first.
There is a ceiling on the subtenant's exposure
Even where the subtenant can be reached, the amount is capped. The article says the sublessee shall not be responsible beyond the amount of rent due from him, in accordance with the terms of the sublease, at the time of the extra-judicial demand by the lessor. Two limits are packed into that. First, the measure is what the subtenant owes under the sublease, not the possibly larger rent in the main lease. Second, the amount is fixed as of the owner's demand made outside court. A subtenant who owes little or nothing under the sublease at that moment cannot be made to answer for more, whatever the main tenant's total debt happens to be.
Advance rent may not count
There is a trap for a subtenant who has already paid ahead. The provision states that payments of rent in advance by the sublessee shall be deemed not to have been made, so far as the lessor's claim is concerned, unless said payments were effected in virtue of the custom of the place. In plain terms, prepaying the sub-landlord does not automatically protect the subtenant against the owner's claim. Unless local custom supports the advance payment, the owner can proceed as though it never happened, and the subtenant may end up effectively paying twice for the same period.
What this means for you
For an owner, the message is that the sublease is a secondary source of recovery: pursue the main tenant first, and understand that what the subtenant can be made to pay is limited to the subtenant's own arrears at the time of demand. For a subtenant, the message is to keep proof of what was actually owed and paid under the sublease, and to be cautious about paying rent far in advance. Because the numbers and the timing of the demand decide how much anyone owes, it is sensible to have the two contracts read together before responding to a demand.