Short answer: it depends on what you sign.
Long answer: make sure to read EVERYTHING in your contract. Don't sign if it doesn't work for you. Ask for changes if you feel comfortable doing so.
Some publishers purchase all rights to a piece, which include all markets, print, and online, forever. They own the piece, and you have no further rights to publish it anywhere in that case. Some purchase all or some of those rights for a period of time, or "first publishing" rights, or "first publishing" in a certain geographical area (ex. first North American rights). After that time, you can do whatever you want with the piece again.
Other publishers will ask for non-exclusive rights, which allows you to pretty much do whatever you want.
Publishing a smaller chunk of your longer story, if you have given exclusive rights, could be problematic (exceptions could include if you link to the longer version). I think it would probably be an icky court situation.
Publishing the longer story after you've given rights to the shorter story would likely be less problematic, but you'd still be risking legal stuff, especially if the publisher is in a particularly litigious place like the US or France.
Basically, if you have a goal of doing something like this, I'd ask the first publisher about it explicitly, and have a clause designated to the issue added to the contract. That way you're completely covered.
I've read others who suggest just going for double publication (of the same work, so a slightly different concern) without asking or informing other outlets. Personally, I think that's a disaster waiting to happen, and being up-front works best. I always let editors/publishers know 1) if a work has been published elsewhere and 2) that I'm submitting it multiple places.
On that topic, I have found for myself that I'm actually much more likely to sell a piece (and quickly) when I inform the publisher that I'm also submitting it elsewhere. For example, an outlet that says it takes 5-7 weeks to respond to submissions responded and accepted within 2 days, since they didn't want the work to be snapped up by anyone else first. I find that publishers appreciate knowing the status of other submissions, and I'd imagine they see this transparency in a favorable light (though I have no direct proof of this outlook other than the thanks I receive).
And a final note on contracts: make sure what you sign has all of the following: length of the piece, exact pay, when and how you'll be paid, if exclusive rights the specifics of time length and region, and especially if your work is not yet written, deadlines. It may be useful to have an attorney quickly review them; if you use a service like LegalShield you have x amount of attorney hours per month included, so it can be easy and cheap.
This is a horribly-designed site, but if your eyes can stand it, it has good information: http://www.writing-world.com/rights/rights.shtml
Here's one of the people who argues that you should just go ahead with simultaneous submissions and not tell anyone: https://www.pitchtravelwrite.com/simultaneous-submissions.html