Yes, both are correct. However, there's no other way with the same meaning, because:
1) "darfst" is the conjugated verb and must be in second position (main clause).
2) "rauchen" is an infinitive and must be at the end
3) "nicht" must be placed directly in front of the part of the sentence it negates, which is "rauchen".
If you move "nicht", the meaning changes:
Du darfst NICHT HIER rauchen = not here, but maybe some other place
NICHT DU darfst hier rauchen = you are not allowed to, but maybe someone else
In general, word order is flexible (except for verbs), but there's something like a natural order (with somewhat complex rules), and if you deviate from that order, parts of the sentence get emphasized (usually the first and/or the last part, e.g. "hier" and "du" in your example).